I want to model a for loop system in Simulink, how I can model the following MATLAB syntax into Simulink model?
N=3;
for i=0:1:N
sum(i+1)=factorial(i)/factorial(N);
end
I have tried for loop sub systems in Simulink and also Sum block for iteration loop but doesn't help me. factorial function can be calculated with FCN function. Suggest me the ways to resolve this model with step time.
factorial(i)/facrorial(N)to1/prod(i+1:N). That will save computations an avoid overflow (ifNis large). Also, it's best not to useias a variable name - Luis Mendofor i=byfor ii=; and replacefactorial(N)/(factorial(i)*factorial(N-i))byprod((N-ii+1:N)./[1:ii])- Luis Mendo