if true % clear;
clc;t=[0 20];y0=[1 0];[t,y] = ode45(@(t,y) sfunc(t,y),t,y0);plot(t,y(:,1),'blue');hold on;pfirst=find(t==0);plast=find(t==20);plot(t,y(:,2),'red');title('a simple harmonic oscillator with ODE45');xlabel('time t');ylabel('y1(metres) y2(metres/sec)');legend('y1','y2');function dydt=sfunc(~,y)dydt=zeros(2,1);w=0.3;dydt(1)=y(2);dydt(2)=(-w^2)*y(1);endend
MATLAB: Can i mark the first point and the last point on the plot
markerplot
Best Answer