problem with subs function

4 views (last 30 days)
Mariam Yehia
Mariam Yehia on 21 Apr 2017
Commented: Walter Roberson on 21 Apr 2017
hello here is my program....it substitutes the value for the first run only; then the symbols appear again!
syms La Lb Lc
Ia=(20+6*La+.02*La^2);
Ib=(25+5.5*Lb);
Ic=(20+6.5*Lc+.005*Lc^2);
IHRa=diff(Ia,La)
IHRc=diff(Ic,Lc)
for L=0:10:90
if L<=30
Lb=L
else
Lb=30;
b=L-Lb
ihr_a=subs(IHRa,La,b)
ihr_c=subs(IHRc,Lc,b)
p=ihr_a-ihr_c
end
end
  1 Comment
Walter Roberson
Walter Roberson on 21 Apr 2017
When I try, I appear to get substituted values each time.
I am not sure what you mean by "the first run". Your "if L<=30" statement is true for L = 0, 10, 20, and 30, and in those cases the only action you request is Lb=L .
Perhaps your "end" for your "if" is too late? Should it be
for L=0:10:90
if L<=30
Lb=L
else
Lb=30;
end
b=L-Lb
ihr_a=subs(IHRa,La,b)
ihr_c=subs(IHRc,Lc,b)
p=ihr_a-ihr_c
end

Sign in to comment.

Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!