How do I plot my differential equation on Matlab?
2 次查看(过去 30 天)
显示 更早的评论
Here is my MATLAB code.
syms v(t) t C1
inflow = 3
peri = .4
Vin = 40
outflow = 4
p = .3
qip = p*inflow
p2 = (v)/(Vin+(inflow-outflow)*(t))
qop = p2*outflow
eqn = diff(v) == qip-qop
S = dsolve(eqn);
pretty(S)
Vp = Vin*peri;
tval = 0;
D = Vp-S
Value = subs(D,tval)
C1 = solve(Value)
tval2 = 7;
Value2 = subs(D,tval2)
C2 = solve(Value2)
V = p*(Vin-tval2)+C1*(Vin-tval2)^(4)
I'm trying to plot Vp and V, but whenever I do, the figure just shows a straight line. It should be something like (tval,Vp) and (tval2,V). Please help, thank you!
0 个评论
回答(1 个)
Star Strider
2021-8-2
Of copurse it’s going to be a straight line!
After evaluating the functions, look at ‘(tval,Vp)’ and ‘(tval2,V)’. They are all constants!
syms v(t) t C1
inflow = 3
peri = .4
Vin = 40
outflow = 4
p = .3
qip = p*inflow
p2 = (v)/(Vin+(inflow-outflow)*(t))
qop = p2*outflow
eqn = diff(v) == qip-qop
S = dsolve(eqn);
pretty(S)
figure
fsurf(S, [-5 5 0 75])
xlabel('Initial Condition')
ylabel('t')
Vp = Vin*peri
tval = 0;
D = Vp-S
Value = subs(D,tval)
C1 = solve(Value)
tval2 = 7;
Value2 = subs(D,tval2)
C2 = solve(Value2)
V = p*(Vin-tval2)+C1*(Vin-tval2)^(4)
.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!