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平均值
函数
calc\u SIR\u mean
应根据用户数返回平均值(您的问题不清楚您是如何接收此值的)。我不明白您的意思,您能解释一下吗?实际上,我想做一个循环,计算满足条件的用户数。我已将任意用户数固定为某个值N=6,并将阈值固定为6。现在我想比较我的输出值和阈值,如果我的输出小于阈值,那么结果应该显示N=6,否则循环应该减少用户数的计数器,然后检查是否满足条件。