plot 2D graph
8 views (last 30 days)
Show older comments
Hi , I have 2 below Eq. :
diff(V,t) = V-V.^3/3-U+2;
diff(U,t) = 1.25*(V-U+0.9);
I want to plot U'-V' plot. I don't know how to do this.
can anybidy help me please.
thanks
1 Comment
Walter Roberson
on 29 Jun 2019
It appears that you will need to work numerically, as the system is difficult to solve symbolically.
Answers (1)
Star Strider
on 29 Jun 2019
Try this:
syms t U(t) V(t) Y
Eqs = [diff(V,t) == V-V.^3/3-U+2; diff(U,t) == 1.25*(V-U+0.9)];
[VF,Sbs] = odeToVectorField(Eqs);
UVfcn = matlabFunction(VF, 'Vars',{t,Y});
Sbsc = sprintfc('%s',Sbs);
ic = [0; 0];
tv = linspace(0, 10, 5000);
[ts,UVs] = ode45(UVfcn, tv, ic);
figure
plot(ts, UVs)
grid
figure
plot(UVs(:,1), UVs(:,2))
grid
xlabel(Sbsc(1))
ylabel(Sbsc(2))
for k = 1:numel(ts)
dUV(:,k) = UVfcn(ts(k),UVs(k,:)); % Calculate Derivatives
end
figure
plot(dUV(:,1), dUV(:,2))
grid
lblf = @(x) sprintf('$\\frac{d%s}{dt}$',x);
xlabel(lblf(Sbsc{1}), 'Interpreter','latex')
ylabel(lblf(Sbsc{2}), 'Interpreter','latex')
I will let you explore it to discover how it works.
0 Comments
See Also
Categories
Find more on Calculus 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!