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!