Help with error matrix dimensions must agree

I am trying to graph this streamline function with a rotation T less than B. I keep getting an error that states matrix dimensions must agree for Psi, how do I fix this?
clear all;
clc;
xymax=0.8;
x=linspace(-xymax,xymax,100);
y=linspace(-xymax,xymax,100);
[X,Y]=meshgrid(x,y);
r=sqrt(X.^2 + Y.^2);
sin_th=Y./r;
U=4;
R=0.1;
B= 4*pi*R*U;
T=-8:0.25:B;
Psi=U*(r- R*R./r).*sin_th+((T./(2*pi)).*log(r/R));
figure
contour(X,Y,Psi,-3:0.25:3,'B')

 采纳的回答

Your matrices are (100 x 100), and ‘T’ is (1 x 53).
If you instead create ‘T’ as:
T = linspace(-8, B, 100);
your code works, and produces an interesting plot!

4 个评论

oh thank you! Would this make T < B? I actually wanted to create a plot that looks closer to this Capture.PNG
My pleasure!
The upper limit to to ‘T’ is ‘B’, so that makes T<=B.
I am not certain what you are doing, or what your calculations represent, so I cannot specifically suggest any changes to it based on my understanding of it. If I use:
T = linspace(0, B, 100);
that is, with ‘T’ starting at 0, the plot is closer to your drawing than with ‘T’ starting at -8.
Also, if you use:
axis equal
after the plot, it looks better.
If my Answer helps you solve your problem, please Accept it!
Thanks so much! Very helpful

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Annotations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by