Error using / Matrix dimensions must agree
2 次查看(过去 30 天)
显示 更早的评论
My script is this:
r=linspace(-180,180,360);
t=linspace(-180,180,360);
[R,T]=meshgrid(r,t);
phi_=6*r*cos(1+5^2/R.^2)-T;
contour(R,T,phi_)
but matlab throws the following error: Error using / Matrix dimensions must agree.
What am i doing wrong?
0 个评论
采纳的回答
Voss
2022-6-28
Use ./
r=linspace(-180,180,360);
t=linspace(-180,180,360);
[R,T]=meshgrid(r,t);
% phi_=6*r*cos(1+5^2/R.^2)-T;
phi_=6*r*cos(1+5^2./R.^2)-T;
contour(R,T,phi_)
2 个评论
Voss
2022-6-28
编辑:Voss
2022-6-28
You're welcome!
As @Star Strider points out, you probably intend to use .* as well, but using / instead of ./ is what caused the error.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!