How can I plot this second-order differential equation
조회 수: 1 (최근 30일)
이전 댓글 표시
![](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
답변 (1개)
Alan Stevens
2020년 10월 27일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!