Borrar filtros
Borrar filtros

How can I adjust the slope field for my DE?

15 visualizaciones (últimos 30 días)
Anthony Aquino
Anthony Aquino el 14 de Mzo. de 2023
Respondida: Abhijeet el 6 de Abr. de 2023
I am currently learning about differential equations and their slope fields. I have a program that allows me to plot this, however, I am having difficulties adjusting the arrows since I am using an unusual equation. How should I adjust the program to work for my DE? I am new to MATLAB so I would appreciate if someone could explain my errors and how to fix them. This is what I have:
[x,y]=meshgrid(-0.1:0.05:1136.15, -0.1:0.05:7);
dy = -((0.1)^2/sqrt(10)^2)*sqrt(2*9.8*y); %Plug in equation
norm=sqrt(dy.^2+1^2);
quiver(x,y,ones(size(x))./norm,dy./norm,1);
xline(0), yline(0)
hold on
f=@(x,y) -((0.1)^2/sqrt(10)^2)*sqrt(2*9.8*y); %Plug in equation
[x,y]=ode45(f,[0 1136.15], 2*sqrt(10));
y(y<0)=nan;
plot(x,y,'lineWidth',1)
xline(0), yline(0)
title('Directional Graph of DE')
xlabel('Time (min)'), ylabel('Water Level (m)')

Respuestas (1)

Abhijeet
Abhijeet el 6 de Abr. de 2023
Hi,
The "quiver" function allows you to plot vector fields, which can be useful when graphing solutions to differential equations. If you're having difficulty adjusting the arrows, you may want to try adjusting the scaling factor in the "quiver" function, which determines the length of the arrows. You can also try changing the step size in the "meshgrid" function to make the arrows closer together or further apart.
% Changing the scaling factor to 0.5 and changing the colors in quiver function
quiver(x,y,1./norm,dy./norm,0.5,'Color',[0 0.5 1]);
Another thing to keep in mind is that the direction of the arrows in the vector field should match the direction of the solutions to the differential equation. In your code, the differential equation is dy = -((0.1)^2/sqrt(10)^2)*sqrt(2*9.8*y), which means that the slope of the solutions is negative. This should be reflected in the direction of the arrows in the vector field.
Hope this will help you resolve your query.
Thanks

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by