How do I display my output for symbolic variables after solving them?
23 views (last 30 days)
Show older comments
Anthony Diaz
on 14 Feb 2021
Commented: Anthony Diaz
on 14 Feb 2021
So I' working on calculating voltage of node's after taking in inputs needed. I succesffuly done so using system of equations. The final step is having on output of test telling the user the voltage, but I don't know to output a 1x1 sym with text.
So I created a system of equations to be solved below:
syms V1 V2 V3
eqn1 = G(1)*V1-G(1)*V2 == G(1)*Vs-G(1)*V2;
eqn2 = G(3)*V2+G(1)*V2-G(1)*V1+G(2)*V2-G(2)*V3 == 0;
eqn3 = G(4)*V3+G(2)*V3-G(2)*V2 == 0;
And solve:
sol = solve([eqn1, eqn2, eqn3], [V1, V2, V3]);
V1Sol = sol.V1;
V2Sol = sol.V2;
V3Sol = sol.V3;
I want to create an output saying, "v2 = " + V1Sol Here's what I have, but an error comes back saying num2str input has to be numeric. Below is what I'd used in the past. Any help displaying a value of a 1x1 sym with text as an output for the user.
Voltage2 = ["v2 = ",num2str(V2Sol)];
disp(Voltate2);
0 Comments
Accepted Answer
James Tursa
on 14 Feb 2021
Convert to double first. E.g.,
Voltage2 = ["v2 = ",num2str(double(V2Sol))];
More Answers (0)
See Also
Categories
Find more on Number Theory 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!