I try to create a loop for which I want to be repeated 10 times. 10 times are enough iterations in order to have at last a constant number.
The loop I create is the following.
I suppose for L_repeat a number (-9999) and after 10 iterations I expect to have the solution in the equation of L_repeat. At the end of each iteration the solution of the equation of L_repeat will be the numbers used in the beginning of the next iteration.
L_repeat=[-9999; -9999; -9999; -9999; -9999; -9999; -9999; -9999]
if Ri_zm(:,1)<0 phi_m_repeat=(1-19.3.*esh_repeat).^(-1/4) phi_H_repeat=0.95.*((1-11.6.*esh_repeat).^(-1/2)) else if Ri_zm(:,1)>0 & Ri_zm(:,1)<=0.2 phi_m_repeat=1+6.*esh_repeat phi_H_repeat=0.95+(7.8.*esh_repeat) end end
% neutral % φm(ς)=φΗ(ς)= φΕ(ς)=1 if Ri_zm(:,1)<=0.01 & Ri_zm(:,1)>=-0.01 u_star_repeat=0.40./p_u(:,1) theta_star_repeat=0.40./p_theta(:,1) % unstable και stable (Ri<=0.2) else if Ri_zm(:,1)<-0.01 | Ri_zm(:,1)>0.01 & Ri_zm(:,1)<=0.2 u_star_repeat=0.40./(p_u(:,1).*phi_m_repeat(:,1)) theta_star_repeat=0.40./(p_theta(:,1).*phi_H_repeat(:,1)) end end
No products are associated with this question.
Your for loop statement is not built correctly:
will just give iterations the value 10 and will execute what follows only once. You have to have a vector of values on the right hand side, that defines all the values that the loop variable has to take iteratively. For example:
for iterations = 1 : 10 ... end
I have a doubt about the rest of the code as well. My advice would be to build it progressively, displaying what happens. For example, make a first step:
for ii = 1 : 10 ii end
and observe what happens. Then add a first, small computation in the loop, and check again that it is working, until you have implemented the full code in a well controlled way.