How to build a plot differential equations
Ältere Kommentare anzeigen
Hi, I'm solving a differential equation and with the given parameters my graph should show a circle, but it's displaying a void, I don't understand why, please help
M8()
function M8
n = 0;b=0; k = 1; a = 1; h = 0; p = 1; y(1)=0; y(2)=1; x=2;
f=@(t,y)[y(2);y(2)+2.*n.*(1+a.*y(1).^3).*y(1)+k.^2.*(y(1)+b.*y(1).^3)-h.*sin(p.*x)];
clc
disp('Значения параметров: n = 0,b=0, k = 1, a = 1, h = 0, p = 1')
disp('Решение задачи Коши для уравнения')
z= ode45(f,[0,1],[0,0]);
disp(z);
tic, [~,y] = ode45(f,[0,1],[0,0]);toc
plot(y(:,1),y(:,2))
grid on
end
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 6 Dez. 2023
n = 0;b=0; k = 1; a = 1; h = 0; p = 1; y(1)=0; y(2)=1; x=2;
f=@(t,y)[y(2);y(2)+2.*n.*(1+a.*y(1).^3).*y(1)+k.^2.*(y(1)+b.*y(1).^3)-h.*sin(p.*x)];
Your h is 0, so h.*sin(p.*x) is going to be 0, so the second entry in f is effectively
y(2)+2.*n.*(1+a.*y(1).^3).*y(1)+k.^2.*(y(1)+b.*y(1).^3)
If you let y(1) and y(2) both be 0, then that evaluates to 0.
Therefore with your h value and with those boundary conditions, your ode is constant 0, 0
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

