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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/574062/image.png)
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!