Extracting numeric values from symbolic variables
Mostrar comentarios más antiguos
I have two matrices say
x=[2 4 9 10];
syms c [1 4];
x==c
it returns
2=c1
4=c2
9=c3
10=c4
However when I write c1 in command window, it returns symbolic 'c1'.
I wanted to extract these numeric values or assign these values to c vector. How one would go around this.
Respuesta aceptada
Más respuestas (3)
Alphonce Owayo
el 23 de Feb. de 2021
2 votos
For example;
syms x y
eqn1=x+y==20;
eqn2=2.3x-9y==13;
soln=vpasolve(eqn1,eqn2);
xsoln=soln.x;
ysoln=soln.y;
or
xsoln=double(soln.x);
ysoln=double(son.y);
disp(xsoln);
disp(ysoln);
madhan ravi
el 6 de Sept. de 2020
1 voto
== forms an equation , it DOESN’T assign any values.
1 comentario
madhan ravi
el 6 de Sept. de 2020
Editada: madhan ravi
el 6 de Sept. de 2020
I would suggest you to do the below instead:
c = num2cell(x);
celldisp(c)
Alphonce Owayo
el 23 de Feb. de 2021
0 votos
shown above is how to extract numeric values from symbolic variables and display them in the command window.
Categorías
Más información sobre Symbolic Math Toolbox 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!