How can I plot this second-order differential equation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/393448/image.png)
here is my start
for t1 = 0:100
for omega = 0.8:0.1:1.5
rhs = @(t,y) [y(2); -0.2.*y(2) + y - y.^3 + 0.3*cos(omega.*t)];
[t1, omega] = ode45(rhs, [0 6], omega);
plot (t1, omega);
end
end
could you help me?
0 Kommentare
Antworten (1)
Alan Stevens
am 27 Okt. 2020
More like this perhaps
omega = 0.8:0.1:1.5;
n = numel(omega);
for i = 1:n
dydt = @(t,y) [y(2); -0.2*y(2) + y(1) - y(1).^3 + 0.3*cos(omega(i)*t)];
tspan = [0 100];
IC = [0 0];
[t, Y] = ode45(dydt,tspan,IC);
y = Y(:,1);
figure
plot(t,y),grid
xlabel('t'),ylabel('y')
title(['\omega = ',num2str(omega(i))])
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!