Syntax for a relational statement within a loop
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I would consider myself to be an "intermediate" level matlab user, however I have come across a problem that drives me absolute mad!!
I have a formula that has two different formulations(depends on some parameters) and this formula is within a loop. I do not know how to write the statement and the loop index together.. here is the part of the code.
Kind regards,
Yunus
for dd=1:size((F_LE),2)-1
#some other stuff that works
%This is the general formulation
del_F_Lk_BL(dd) = sqrt(bf^2*tau_L1*s_L0*Ef*t + (F_LE(dd))^2) - F_LE(dd);
%This one is going to be the formulation only if *F_LE(dd) <= F_Lk_BL_D* and should somehow be written in the left hand side of the below formula:
del_F_Lk_BL(dd) = del_F_Lk_BL_G - (del_F_Lk_BL_G - del_F_Lk_BL_D)/del_F_Lk_BL_D*F_LE(dd);
end
Again, than you very much!!
0 个评论
回答(1 个)
Walter Roberson
2012-5-15
You do not need anything fancy at all, as you are looping over individual dd.
for dd=1:size((F_LE),2)-1
#some other stuff that works
if F_LE(dd) <= F_Lk_BL_D
del_F_Lk_BL(dd) = del_F_Lk_BL_G - (del_F_Lk_BL_G - del_F_Lk_BL_D)/del_F_Lk_BL_D*F_LE(dd);
else
del_F_Lk_BL(dd) = sqrt(bf^2*tau_L1*s_L0*Ef*t + (F_LE(dd))^2) - F_LE(dd);
end
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!