필터 지우기
필터 지우기

'Matrix dimensions must agree' error

조회 수: 1 (최근 30일)
IOANNIS KORACHAIS
IOANNIS KORACHAIS 2020년 11월 14일
답변: Star Strider 2020년 11월 14일
i have this code and it says that the matrix dimensions must agree. What am i doing wrong? I'm really new in matlab.
Re = 190000:10000:290000;
Pr = 3.66:0.5:5.66;
Pr = double(Pr);
Nu = [(0.3+0.62.*Re.^(1/2).*Pr.^(1/3))/(1+(0.4/Pr).^(2/3)).^(1/4)].*(1+(Re/282000))
  댓글 수: 1
IOANNIS KORACHAIS
IOANNIS KORACHAIS 2020년 11월 14일
The 'Pr = double(Pr)' is a mistake i made, i forgot to erase it for this post sorry

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2020년 11월 14일
Vectorise all multiplication, division and exponentiation operations, and it works:
Re = 190000:10000:290000;
Pr = 3.66:0.5:5.66;
[Rem,Prm] = ndgrid(Re, Pr);
Nu = @(Re,Pr) ((0.3+0.62.*Re.^(1/2).*Pr.^(1/3))./(1+(0.4./Pr).^(2/3)).^(1/4)).*(1+(Re/282000))
figure
surf(Rem, Prm, Nu(Rem,Prm))
grid on
.

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by