%20-%202019%2006%2013.png)
How can I plot arrows over a function? (For ODE solution)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Oscar Ramos Soto
le 14 Juin 2019
Réponse apportée : Star Strider
le 14 Juin 2019
Hi! I want to plot arrows over a function , for example if I have a Sin(x) function, plot the arrows and its directions.
Maybe I'm not clear, so I'll let an example down here.
I've tried using quiver() but I cant get the results as the image below.
Thanks a lot..png)
.png)
0 commentaires
Réponse acceptée
Star Strider
le 14 Juin 2019
Try this:
t = linspace(0, 2, 25);
h = t(2)-t(1);
s = sin(2*pi*t/max(t));
ds = gradient(s,h);
dt = gradient(t,h);
figure
quiver(t,s, dt,ds)
grid
producing:
%20-%202019%2006%2013.png)
This calculates the derivative from the data (here sin(t)). You may be able to recover your derivative directly from your ODE, so you may not need to calculate the gradient of your solved vector. I will leave that for you to determine.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!