how to use the output of 'solve' in another equation

조회 수: 3 (최근 30일)
omnia
omnia 2011년 12월 5일
Hi everyone I used 'solve' function to solve an equation and got a variable 'v' then I converted it to double. The problem is when I wrote two equations with two variables x and y which contain v as a constant, I did not get the values of x and y but instead a symbolic expression in v. How can I make the program substitute with the value of v I already got from the first step. v=double(solve('3*v/5+v+8')); S=solve('x+y=1','x-11*y=-v'); yield a solution in v S.x=11/12-1/12*v S.y=1/12*v+1/12
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 5일
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup

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

채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 5일
Sx = double(subs(S.x, 'v', v));
Sy = double(subs(S.y, 'v', v));
However, it would be shorter if you used
syms x y
[Sx Sy] = double( solve('3*v/5+v+8', 'x+y=1','x-11*y=-v', x, y) );
  댓글 수: 2
omnia
omnia 2011년 12월 5일
Thanks very much
omnia
omnia 2011년 12월 5일
when I did 'S.x' in my program I had very long expression (after using simplify)in the form of numerator and denominator as a function of v -although it can be written in much simpler form. when i did 'subs(S.x, 'v', v)' i have NAN.
How can I make the program write it in a simpler way (using 1.2*10^34 for example instead of writing at as 33 number)??

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

추가 답변 (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