phase plotting symbolic system of equations (using ezplot and dsolve)

I'm trying to phase-plot (xsol by ysol) my system of odes:
% the uncoupled linear system
syms x(t) y(t)
A=diag([-1,2]); % creates diagonal matrix
Y = [x; y];
odes = diff(Y) == A*Y;
[xSol(t), ySol(t)] = dsolve(odes);
xSol(t) = simplify(xSol(t))
ySol(t) = simplify(ySol(t))
ezplot(xSol(t),ySol(t))
but i get this error:
Error using sym/ezplot (line 53)
One parameter is expected when plotting a curve.
Error in equations (line 24)
ezplot(xSol(t),ySol(t))

 Accepted Answer

You have to supply numeric (not symbolic) initial conditions:
[xSol(t), ySol(t)] = dsolve(odes, x(0)==1, y(0)==1);

2 Comments

thank you so much. it solved my problem. but can you help me to find what am i missing in order to get what I was supposed to get which is this:
My pleasure.
I suspect that ezplot and fplot are not designed to do what you want.
This will get you started:
t = linspace(0, 2, 20);
figure(1)
for k1 = -5:5
plot(k1*exp(-t), k1*exp(2*t), '-k')
hold on
end
hold off
I leave the rest to you.
If you want arrows as well, see the documentation for the quiver function. Note that ‘u’ and ‘v’ are the derivatives of the functions you are plotting, so use your original differential equations (with the appropriate initial conditions) to calculate them, or use the gradient function to calculate them numerically.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!