solve odes system with conditions
Show older comments
hello
i have to solve odes system with inital conditions
but i dont know where are the mistake in my code :(
clear
clc
%y1=x, y2=x', y3=y, y4=y'.
w = 7.29*10^(-5);
g = 9.8;
syms l
k = sqrt(g/l);
alpha = pi/4;
tmax = 300;
fun=@(t,y)[y(2);2*w*sin(alpha)*y(4)-(k^2)*y(1);y(4);-2*w*cos(alpha)*y(2)-(k^2)*y(3)];
x0= 1; %supply x(t0)
x0prime = 0; %supply x'(t0)
y0 = 0; %supply y(t0)
y0prime = 0; %supply y'(t0)
Y0 = [x0,x0prime,y0,y0prime];
% Define the range of t
tspan= [0 tmax];
[T,Y]=ode45(fun,tspan,Y0)
figure
plot(T,Y(:,1),'b-') %plot x
hold on
plot(T,Y(:,3),'g-') %plot y
xlim([0 23])
Answers (1)
Star Strider
on 21 Aug 2020
Edited: Star Strider
on 21 Aug 2020
0 votes
See my latest Comment to your previous Question: how to solve two differential equations with conditions
If my Answer helped you solve your problem, please Accept it!
.
Categories
Find more on Ordinary Differential Equations 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!