MATLAb Solve function not solving
Show older comments
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])
Accepted Answer
More Answers (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])
Star Strider
on 21 Oct 2024
Edited: Star Strider
on 21 Oct 2024
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])
Categories
Find more on Common Operations 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!