MATLAB: I’m trying to take the grid points x and y and the velocities Vx and Vy to plot the streamlines using streamline starting at x = −4 and 21 and y locations between -4 and 4.

streamlines

clc
clear all
close all
Vo= 10;
Po = 101000;
rho = 1.225;
R =1;
x = linspace(-4,4,1000);
y = linspace(-4,4,1000);
[X,Y] = meshgrid(x,y);
r = sqrt(x.^2 +y.^2);
theta = atan(y/x);
Vr = 1-((R^2)./(r.^2)).*Vo.*cos(theta);
Vt = -(1- (R^2./r.^2).*Vo.*sin(theta));
Vx = (Vr.*cos(theta) - Vt.*sin(theta));
Vy = (Vr.*sin(theta) - Vt.*cos(theta));
P = 5.*rho.*(Vo^2 - Vx.^2 - Vy.^2)+ Po;
figure
pcolor(X,Y,hypot(Vx,Vy))
shading interp
h=streamline(X,Y,Vx,Vy);
set(h,'color','red')

Best Answer

clc
clear all
close all
Vo= 10;
Po = 101000;
rho = 1.225;
R =1;
x = linspace(-4,4,1000);
y = linspace(-4,4,1000);
[X,Y] = meshgrid(x,y);
r = sqrt(X.^2 +Y.^2);
theta = atan(Y./X);
Vr = 1-((R^2)./(r.^2)).*Vo.*cos(theta);
Vt = -(1- (R^2./r.^2).*Vo.*sin(theta));
Vx = (Vr.*cos(theta) - Vt.*sin(theta));
Vy = (Vr.*sin(theta) - Vt.*cos(theta));
P = 5.*rho.*(Vo^2 - Vx.^2 - Vy.^2)+ Po;
figure
pcolor(X,Y,hypot(Vx,Vy))
shading interp
h=streamline(X,Y,Vx,Vy);
set(h,'color','red')
Related Question