MATLAB: How to solve simple differential equations

how to solve simple differential equations

Hi all,
How can I solve this equation?!
dx/dt+y=0
dy/dt-x=0
x(0)=3/2
y(0)=0
Thanks

Best Answer

This way, if you have the Symbolic Math Toolbox:
syms x(t) y(t)
[x,y] = dsolve(diff(x) + y == 0, diff(y) - x == 0, x(0)==3/2, y(0)==0)
x =
(3*cos(t))/2
y =
(3*sin(t))/2