Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的程序中,假设我解决了问题。的用户N=6。SIR 的阈值SIRo=6;生成的输出是SIRmean=10(假设)。
N=6
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
您可以使用带有递减计数器和条件中断的简单 for 循环:
N=6; for k=N:-1:0 SIRmean = calc_SIR_mean(N); if SIRmean < SIRo disp(['N=' k]) break; end end
函数calc_SIR_mean应该根据用户数量返回平均值(从你的问题中不清楚你是如何收到这个值的)。
calc_SIR_mean