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))

 채택된 답변

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

댓글 수: 2

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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2017년 10월 6일

댓글:

2017년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by