필터 지우기
필터 지우기

How can I plot this second-order differential equation

조회 수: 1 (최근 30일)
Hyun Suk Song
Hyun Suk Song 2020년 10월 27일
답변: Alan Stevens 2020년 10월 27일
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?

답변 (1개)

Alan Stevens
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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by