How to build a plot differential equations
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 6 Déc 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
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

