How to use quiver with equations in function?
Afficher commentaires plus anciens
I have defined several functions with equations like
function dZ = ODE(~,z)
x = z(1);
y = z(2);
dZ = [x+y;...
4*x-2*y];
end
These functions are used by other functions for solving etc. Now I want to do plotting with quiver but I don't figure out how to pass a function with equations as a parameter to quiver. It should look like this:
odehandle = str2func('ODE');
plot_vectorfield(odehandle);
function plot_vectorfield(odehandle)
[x,y]=meshgrid(-10:1:10,-10:1:10);
[dx,dy]=odehandle; %does not work!
quiver(x,y,dx,dy);
end
So the problem is obviously how to pass the u,v parameter to quiver. I would also like to know how to handle function defined equation systems with 3 equations with quiver. Thanks a lot!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Vector Fields 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!