About solve function in Symbolic Math Toolbox

1 次查看(过去 30 天)
Hi,
I am using the Symbolic Math Toolbox to solve a linear system of equations. After solving it, I am getting the following result for one of the variables:
>> vpa(s.C2)
ans =
0.0000000069099524659921582499451534399493*q2 +
0.0000000069099524659921582499451534399493*q3 +
0.0074738045872171184378875461963896
I just one to get the coefficient of the first term, the coefficient of the second term and the third term of that solution and assign them to a variable, say, a(1), a(2) and a(3), respectively, so I have:
a(1)=0.0000000069099524659921582499451534399493;
a(2)=0.0000000069099524659921582499451534399493;
a(3)=0.0074738045872171184378875461963896;
Is there any way to do this?
Thank you!

采纳的回答

Sean de Wolski
Sean de Wolski 2013-6-6
syms x
y = vpa('pi*x+exp(1)*x^2')
a = coeffs(y)
In general to discover this stuff I would recommend using:
methodsview(y)
This will show you all of the available methods for the output.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by