フィルターのクリア

How to plot the opposite direction field

2 ビュー (過去 30 日間)
EA
EA 2020 年 12 月 7 日
編集済み: Ameer Hamza 2020 年 12 月 7 日
I have this code written for the flow field. But I want the opposite to happen, the image below should be inside out. The longest direction lines should be on the inside and the outside should have the smallest direction lines. It should be inside out, if that makes sense
%Define parameters for the velocity profile
w=2*pi; %rad/s
R=15; %cm
%Create a meshgrid of cylindrical coordinates
[r,theta]=meshgrid(R:R/10:0,2*pi:pi/12:0);
%Define the Cartesian coordinates
x=r.*cos(theta);
y=r.*sin(theta);
%Calculate the linear velocity components in cartesian coordinates
u=-w.*r.*sin(theta);
v=w.*r.*cos(theta);
%Create a 2d vector plot of the velocity
quiver(x,y,u,v);
daspect([1 1 1]);
xlabel('x, cm');
ylabel('y, cm');
title('Title')
%Define the axis ranges
axis([-R R -R R]);

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 7 日
Try this
quiver(x, y, 1./u, 1./v);
  2 件のコメント
EA
EA 2020 年 12 月 7 日
That does not work. The meshgrid comes out blank
Ameer Hamza
Ameer Hamza 2020 年 12 月 7 日
編集済み: Ameer Hamza 2020 年 12 月 7 日
The suggestion about meshgrid was given by VBBV. I only suggested to modify quiver() line. Anyway, try the following code
%Define parameters for the velocity profile
w=2*pi; %rad/s
R=15; %cm
%Create a meshgrid of cylindrical coordinates
[r,theta]=meshgrid(R/10:R/10:R,0:pi/10:2*pi);
%Define the Cartesian coordinates
x=r.*cos(theta);
y=r.*sin(theta);
%Calculate the linear velocity components in cartesian coordinates
u=-w.*1./r.^(1/2).*sin(theta);
v=w.*1./r.^(1/2).*cos(theta);
%Create a 2d vector plot of the velocity
quiver(x,y,u,v);
daspect([1 1 1]);
xlabel('x, cm');
ylabel('y, cm');
title('Title')
%Define the axis ranges
axis([-R R -R R]);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by