How do I display my output for symbolic variables after solving them?

조회 수: 23 (최근 30일)
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);

채택된 답변

James Tursa
James Tursa 2021년 2월 14일
Convert to double first. E.g.,
Voltage2 = ["v2 = ",num2str(double(V2Sol))];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by