Passing a multi-variable function into quiver function

4 views (last 30 days)
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

Accepted Answer

DGM
DGM on 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

More Answers (0)

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!