Error using + Matrix dimensions must agree. Pleasee Helppp
Afficher commentaires plus anciens
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 ;
Réponses (1)
James Tursa
le 14 Nov 2017
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 commentaires
Kim Hao Teong
le 14 Nov 2017
Modifié(e) : Kim Hao Teong
le 14 Nov 2017
Adam
le 14 Nov 2017
Clearly you haven't if you are getting different sized matrices to add together!
Kim Hao Teong
le 14 Nov 2017
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

