Passing a multi-variable function into quiver function

4 visualizzazioni (ultimi 30 giorni)
When I try to use the below code, I successfully plot a flow field, however, it is obviously wrong because there is no x-compononent of the field whatsoever and the y-component is constant throughout. I am pretty sure it has something to do with using a multivariable function in quiver, but I do not know how I would go about fixing this. Any help is appreciated. Thanks.
clear all;
[x,y] = meshgrid(-150:5:150,-150:5:150); % x and y values for velocity field
u = (-1.5*(x^2))-((1/3)*x^3); % u velocity function
v = (3*x*y)+(y*x^2); % u velocity function
figure;
quiver(x,y,u,v);
axis([-150 150 -150 150]); % fix axis to desired range
title({'Velocity and Streamline plots'}) % plot title

Risposta accettata

DGM
DGM il 6 Apr 2021
Maybe you meant this:
u = (-1.5*(x.^2))-((1/3)*x.^3); % u velocity function
v = (3*x.*y)+(y.*x.^2); % u velocity function
otherwise both u and v will be constant arrays

Più risposte (0)

Categorie

Scopri di più su Vector Fields in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by