MATLAb Solve function not solving
이전 댓글 표시
I am trying to solve a system of equations in Matlab, however when I run the code below, it doesn't return an answer for I1, I2 and V0, although there 3 equations and 3 variables. I need some help.
clear all
close all
syms I1 I2 V0
s=2;
eqns=[5*I1+4*I2+1/(s*0.1)*I1+2*s*I1==1, 4*I2-3*V0==0, V0==I1*(2*s)];
S=solve(eqns,[I1,I2,V0])
채택된 답변
추가 답변 (3개)
Which MATLAB version are you using ? R2024b gives a direct answer:
clear all
close all
syms I1 I2 V0
s=2;
eqns=[5*I1+4*I2+1/(s*0.1)*I1+2*s*I1==1, 4*I2-3*V0==0, V0==I1*(2*s)];
S=solve(eqns,[I1,I2,V0])
Your code works in R2024b —
clear all
close all
syms I1 I2 V0
s=2;
eqns=[5*I1+4*I2+1/(s*0.1)*I1+2*s*I1==1, 4*I2-3*V0==0, V0==I1*(2*s)];
S=solve(eqns,[I1,I2,V0])
format long
I1 = double(S.I1)
I2 = double(S.I2)
V0 = double(S.V0)
Consider upgrading, if that is an option. (I no longer have access to R2019a to see if there could be a work-around.)
EDIT — Changed vpa calls to double, since symbolic results no longer appear here after a post is submittted.
.
Seems to work fine here
clear all
close all
syms I1 I2 V0
s=2;
eqns=[5*I1+4*I2+1/(s*0.1)*I1+2*s*I1==1, 4*I2-3*V0==0, V0==I1*(2*s)];
S=solve(eqns,[I1,I2,V0])
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!