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!!

回答(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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by