Options for output of solve function with sequential variables

Ladies and Gents,
I'm working on a code which checks the order of a polynomial and then creates that number (n=order + 1) of unknown variables. I then create a system of n linear equations and solve them using the solve function.
My current issue is being able to output the results to a 'n' variable array and THEN access the variables in a for loop for substitution. I have a 1xn symbolic array, but when I attempt to equate solve to it, it ignores the array and creates a struct.
syms t
S = sym('S', [1 (order+1)]);
A = sym('A', [1 (order+1)]);
lhs=(myequationoft1); %These are symbolic equations my code generates
rhs=(myequationoft2); %Each is a function of symbolics t and S1,S2,...SN
eqns=sym(zeros(order+1,1)); %Creates symbolic array which I can assign the equations to...
for i=1:(order+1)
eqns(i)=(subs(diff(lhs,(i-1)),t,0)==subs(diff(rhs,(i-1)),t,0));
%Assigns the (i-1)th derivative of each equation evaluated at t=0 to eqns(i)
end
A=solve(eqns,S); %This is my issue.... Straight assignment creates a struct
%I want to be able to access the items (A.S1,A.S2,...A.SN) in a for loop

更多回答(0 个)

类别

帮助中心File 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