problem in solve function
Mostrar comentarios más antiguos
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 comentarios
KSSV
el 6 de En. de 2016
Can you copy the code here, which gave you that structure? It makes solution easy.
mahmud man
el 6 de En. de 2016
Editada: Walter Roberson
el 6 de En. de 2016
Respuestas (1)
Walter Roberson
el 6 de En. de 2016
Editada: Walter Roberson
el 6 de En. de 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 comentarios
mahmud man
el 6 de En. de 2016
Walter Roberson
el 6 de En. de 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{:});
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!