필터 지우기
필터 지우기

How can I solve & this 2nd order differential equation?

조회 수: 1 (최근 30일)
Keith Grey
Keith Grey 2020년 6월 11일
편집: Ameer Hamza 2020년 6월 12일
% x = x''
% y = x'
% z = x
% Conditions
f = 50:1:200; % Frequency span (Hz)
for f = 50:1:200
Equation = 50x - 100y - 25z == -1(f * 2 * pi);
plot(f, Equation)
hold on
end

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 6월 12일
편집: Ameer Hamza 2020년 6월 12일
This shows how to solve this ODE for all values of 'f', and plot the solution as a surf plot
f = 50:1:200;
t = linspace(0, 10, 1000); % solve the equation for t in [0, 10]
ic = [0; 0]; % initial condition
Y = zeros(numel(f), numel(t));
for i = 1:numel(f)
[~, y] = ode45(@(t, x) odeFun(t, x, f(i)), t, ic);
Y(i, :) = y(:, 1);
end
surf(t, f, Y);
shading interp
xlabel('t');
ylabel('f');
zlabel('x');
function dxdt = odeFun(t, x, f)
dxdt = zeros(2, 1);
dxdt(1) = x(2);
dxdt(2) = 1/50*(100*x(2) + 25*x(1) - 1*2*pi*f);
end
Also see this example: https://www.mathworks.com/help/matlab/ref/ode45.html#bu3uj8b. It shows how to convert the 2nd-order ODE into a system of 2 first-order ODEs.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by