problem in solve function
Show older comments
hello I write a m-file that gets the number of equation and solve a system of equation.i use 'solve' function to calculate the roots of system but i get the answer in a structure format and for every roots i must enter the format "q.w1_1" for example. i want to ask how can i get the whole roots in a matrix format?i write the answer of matlab bellow. thank you
q =
w10_1: [1x1 sym]
w10_2: [1x1 sym]
w10_3: [1x1 sym]
w10_4: [1x1 sym]
w10_5: [1x1 sym]
w10_6: [1x1 sym]
w10_7: [1x1 sym]
w10_8: [1x1 sym]
w10_9: [1x1 sym]
w10_10: [1x1 sym]
w1_1: [1x1 sym]
w1_2: [1x1 sym]
w1_3: [1x1 sym]
w1_4: [1x1 sym]
w1_5: [1x1 sym]
w1_6: [1x1 sym]
w1_7: [1x1 sym]
w1_8: [1x1 sym]
w1_9: [1x1 sym]
2 Comments
KSSV
on 6 Jan 2016
Can you copy the code here, which gave you that structure? It makes solution easy.
mahmud man
on 6 Jan 2016
Edited: Walter Roberson
on 6 Jan 2016
Answers (1)
Walter Roberson
on 6 Jan 2016
Edited: Walter Roberson
on 6 Jan 2016
struct2cell(q)
and you might want to cell2mat() the result of that.
But remember that when you do these, you are making a result that depends upon the order of the symbols -- dependent, for example, on the fact that w10_1 sorts before w1_1 because '0' sorts before '_' .
2 Comments
mahmud man
on 6 Jan 2016
Walter Roberson
on 6 Jan 2016
If you are looking for the double precision value equivalent then
bb = structfun(@double,q);
If you are looking for the answer still in symbolic form then
aa = struct2cell(q);
bb = vertcat(qq{:});
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!