problem with subs function

조회 수: 5 (최근 30일)
Mariam Yehia
Mariam Yehia 2017년 4월 21일
댓글: Walter Roberson 2017년 4월 21일
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
Walter Roberson
Walter Roberson 2017년 4월 21일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by