Matlab 如何制作一个自动显示程序输出的循环

Matlab 如何制作一个自动显示程序输出的循环,matlab,octave,Matlab,Octave,在我的程序中,假设我固定了用户数N=6。 SIR的阈值SIRo=6;生成的输出是SIRmean=10(假设) 我想做一个循环,这样 if SIRmean < SIRo disp N=6 else decrease the counter till SIRmean> SIRo and display the value of N for which this condition holds true. end if SIRmeanSIRo 并显示此条件为真的N

在我的程序中,假设我固定了用户数
N=6
。 SIR的阈值
SIRo=6
;生成的输出是
SIRmean=10
(假设)

我想做一个循环,这样

if SIRmean < SIRo

   disp N=6

else

  decrease the counter till SIRmean> SIRo
   and display the value of N for which this condition holds true.

end
if SIRmeanSIRo
并显示此条件为真的N值。
结束

您可以使用带有下行计数器和断开条件的简单for循环:

N=6;
for k=N:-1:0
   SIRmean = calc_SIR_mean(N);
   if SIRmean < SIRo
      disp(['N=' k])
      break;
   end
end
N=6;
对于k=N:-1:0
SIRmean=计算SIR平均值(N);
如果SIRo平均值