Passing a multi-variable function into quiver function

1 次查看(过去 30 天)
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

采纳的回答

DGM
DGM 2021-4-6
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by