How to extract results from ans of solve command?

조회 수: 14 (최근 30일)
Luiz
Luiz 2014년 12월 8일
편집: Andrew Newell 2014년 12월 8일
Hi,
I've tried to solve a 2 equation system with the solve command and I don't know if it is possivle to extract vales from the answer. Please, what can be done?
syms n p Rs Rr An1 An2 Bn1 Bn2 mir theta Mn An1 Bn1
bc1=(n*p/Rs)*(An1*Rs^(n*p)+Bn1*Rs^(-n*p))*sin(n*p*theta)
bc2=(n*p*(sin(n*p*theta)*(An1*Rr^(n*p) + Bn1/Rr^(n*p)) - (Mn*Rr*sin(n*p*theta))/(mir*(n^2*p^2 - 1))))/Rr
solve (bc1, bc2, An1, Bn1)
ans =
An1: [1x1 sym]
Bn1: [1x1 sym]
Thank you,
Luiz Loureiro

답변 (1개)

Andrew Newell
Andrew Newell 2014년 12월 8일
편집: Andrew Newell 2014년 12월 8일
First, it's a good idea to give a meaningful name to the output of solve:
sols = solve (bc1, bc2, An1, Bn1);
Now you can look at the solutions using
sols.An1
or
disp(sols.An1)
(which looks a little cleaner)
and
sols.Bn1

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by