Error using fzero. I don't know where to place the (.) properly. Please help

4 ビュー (過去 30 日間)
mscv
mscv 2013 年 8 月 1 日
Here's the error code:
Error using fzero (line 289)
FZERO cannot continue because user supplied function_handle ==>
@(f)(1/sqrt(f)+0.86*2.303*log(E(a)./3.7+2.51/(Re.*sqrt(f))))
failed with the error below.
Matrix dimensions must agree.
Error in LBYCHEH_EA2_Ex42_ChengVillalva_CindyMako (line 11)
z = fzero(x,30)
Codes:
Re = 1500:15000;
E = [0.00001;0.00005;0.0001;0.0005;0.001;0.005;0.01;0.03;0.05;0.07;0.09;0.1];
hold all;
a = 1;
while a<12
f = 0.16*Re.^(-0.16)
x = @(f)(1/sqrt(f) + 0.86*2.303*log(E(a)./3.7 + 2.51/(Re.*sqrt(f))))
z = fzero(x,30)
loglog(Re,z);
a = a + 1;
end
grid on;
title('Colebrook-White Moody Chart');
xlabel('Reynolds number, Re');
ylabel('Fanning friction factor, f');

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 8 月 1 日
At a quick glance you are missing a dot '.' after 2.51
x = @(f)(1/sqrt(f) + 0.86*2.303*log(E(a)./3.7 + 2.51./(Re.*sqrt(f))))
Try that
  3 件のコメント
Shashank Prasanna
Shashank Prasanna 2013 年 8 月 1 日
You use f twice. You may want to use a different variable
f = 0.16*Re.^(-0.16)
x = @(f)(1/sqrt(f) + 0.86*2.303*log(E(a)./3.7 + 2.51/(Re.*sqrt(f))))
mscv
mscv 2013 年 8 月 1 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOptimization Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by