필터 지우기
필터 지우기

A question related to subs in ode (symbolic maths toolbox)

조회 수: 2 (최근 30일)
Angus Wong
Angus Wong 2019년 7월 3일
댓글: Angus Wong 2019년 7월 3일
I have a line:
ode=diff(y,x)==x+y;
I want matlab to calculate diff(a,b), given a and b are real numerical values. However, the subs function allowed me only to either sub the value a or value b into the ode line, can anyone help?
I am expecting something like subs(ode,[x,1,y,2]) would give me 3, subs(ode,[x,4,y,5]) would give me 9.

채택된 답변

madhan ravi
madhan ravi 2019년 7월 3일
I am not sure what you are asking for perhaps an example below?:
>> syms x y
>> eqn = x+2*y
eqn =
x + 2*y
>> subs(eqn,{x,y},{2,5})
ans =
12
>>
  댓글 수: 2
madhan ravi
madhan ravi 2019년 7월 3일
Perhaps ?:
>> syms y(x)
>> ode=diff(y,x)==x+y;
>> subs(rhs(ode)-lhs(ode),{x,y},{1,2})
ans(x) =
3
>> subs(rhs(ode)-lhs(ode),{x,y},{4,5})
ans(x) =
9
>>
Angus Wong
Angus Wong 2019년 7월 3일
Thanks a lot! You do make my day.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by