How can I solve & this 2nd order differential equation?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
% 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
0 Kommentare
Antworten (1)
Ameer Hamza
am 12 Jun. 2020
Bearbeitet: Ameer Hamza
am 12 Jun. 2020
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations 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!