Syntax for a relational statement within a loop

1 view (last 30 days)
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!!

Answers (1)

Walter Roberson
Walter Roberson on 15 May 2012
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 Comment
Yunus Harmanci
Yunus Harmanci on 15 May 2012
Thank you very much Walter, apparently I was too posh to do a basic if statement. :) That solved my problem, thanks!

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!