Can someone quickly help me with this? It is a second ODE question that needs to be answered by using MATLAB or python please.
MATLAB script
clc
clear
close
lam=2.8; w=10.3;
t0=0; t_end=5;
y0=[50*pi/180;0];
h=0.01;
fcn1=@(t,xa)[xa(2);-2*lam*xa(2)-w^2*xa(1)];
[t1,y1] = eulersys(t0,y0,t_end,h,fcn1);
fcn2=@(t,x)[x(2); -2*lam*x(2)-w^2*sin(x(1))];
[t2,y2] = eulersys(t0,y0,t_end,h,fcn2);
plot(t1,y1(:,1),t2,y2(:,1))
legend('Problem 2','Problem 3')
xlabel('Time'),ylabel('\theta(t)')
eulersys function
function [t,y] = eulersys(t0,y0,t_end,h,fcn)
m = length(y0);
n = fix((t_end-t0)/h)+1;
t = linspace(t0,t0+(n-1)*h,n)';
y = zeros(n,m);
y(1,:) = y0;
for i = 2:n
% y(i-1,:)
% h*feval(fcn,t(i-1),y(i-1,:))'
y(i,:) = y(i-1,:)+h*feval(fcn,t(i-1),y(i-1,:))';
end
Can someone quickly help me with this? It is a second ODE question that needs to...