Syntax for a relational statement within a loop

1 回表示 (過去 30 日間)
Yunus Harmanci
Yunus Harmanci 2012 年 5 月 15 日
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!!

回答 (1 件)

Walter Roberson
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
  1 件のコメント
Yunus Harmanci
Yunus Harmanci 2012 年 5 月 15 日
Thank you very much Walter, apparently I was too posh to do a basic if statement. :) That solved my problem, thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by