Passing a multi-variable function into quiver function

조회 수: 4 (최근 30일)
Gavin Goddard
Gavin Goddard 2021년 4월 6일
댓글: Gavin Goddard 2021년 4월 6일
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