Error using + Matrix dimensions must agree. Pleasee Helppp

3 ビュー (過去 30 日間)
Kim Hao Teong
Kim Hao Teong 2017 年 11 月 14 日
コメント済み: Kim Hao Teong 2017 年 11 月 14 日
if true
% code
endRelRough = [0.00001 0.00005 0.0001 0.0002 0.0004 0.0006 0.0008 0.001 0.002 0.004 0.006 0.008 0.01 0.015 0.02 0.03 0.04 0.05];
ReL = [600:100:3900];
FCL = 64./ReL;
ReT = [[4e3:1e3:9e3] [1e4:1e4:9e4] [1e5:1e5:9e5] [1e6:1e6:9e6] [1e7:1e7:1e8]];
for i=1:length(RelRough)
for j=length(ReT)
FCT_old=1;
residual=1;
while residual>0
FCT_new=1./(-2*log10((RelRough./3.7)+(2.51./(ReT*sqrt(FCT_old))))).^2 ;
residual=abs(FCT_new-FCT_old);
FCT_old=FCT_new
end
FCT(i,j)=FCT_old
end
end
>> FCLT_kimhaote Error using + Matrix dimensions must agree.
Error in FCLT_kimhaote (line 10) FCT_new=1./(-2*log10((RelRough./3.7)+(2.51./(ReT*sqrt(FCT_old))))).^2 ;

回答 (1 件)

James Tursa
James Tursa 2017 年 11 月 14 日
The error message is very clear. The variables you are trying to add do not have compatible sizes. Specifically
>> size(RelRough)
ans =
1 18
>> size(ReT)
ans =
1 43
>> FCT_new=1./(-2*log10((RelRough./3.7)+(2.51./(ReT*sqrt(FCT_old))))).^2 ;
??? Error using ==> plus
Matrix dimensions must agree.
You need to fix your code so that the operation is compatible.
  3 件のコメント
Adam
Adam 2017 年 11 月 14 日
Clearly you haven't if you are getting different sized matrices to add together!
Kim Hao Teong
Kim Hao Teong 2017 年 11 月 14 日
I dont even know what should I do now

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

カテゴリ

Help Center および File ExchangeFluid Dynamics についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by