Parse error at '<': usage might be invalid MATLAB syntax

2 ビュー (過去 30 日間)
Arupratan Gupta
Arupratan Gupta 2021 年 8 月 26 日
編集済み: Walter Roberson 2021 年 8 月 27 日
% the fluid flow through any of the ipe or chimney can be calculated using
% the realtion of the Moody chart and the Colebrook equation
D = 0:0.1:5;
epsilon = 100:100.5:500;
Re = 2300:2300.5:2900;
f = 0:0.1:10;
i = 0:0.1:1000;
for(i<1100)
1/((f)^2) = -2.0 log[((epsilon/D)/3.7) + ((2.51/Re*((f)^2)))];
plot(f,D);
title('The Moody chart');
  2 件のコメント
Ive J
Ive J 2021 年 8 月 26 日
編集済み: Walter Roberson 2021 年 8 月 27 日
what about learning MATLAB before using :) ?
mathworks.com/learn/tutorials/matlab-onramp.html
DGM
DGM 2021 年 8 月 26 日
編集済み: DGM 2021 年 8 月 27 日
For starters:
% these all have different lengths
% some (e.g. Re) appear to be mistakes
D = 0:0.1:5; % 51 elements
epsilon = 100:100.5:500; % 4 elements
Re = 2300:2300.5:2900; % 1 element
f = 0:0.1:10; % 101 elements
i = 0:0.1:1000; % 10001 elements
% this isn't how a for-loop works
for (i<1100) % this expression is assigned to nothing
% since nothing in the loop depends on the variable that doesn't exist
% what is the purpose of the loop?
% this is an invalid assignment with several internal problems
% the RHS is not a target for assignment.
% log() is the natural log. colebrook eqn needs log10()
% use parentheses, not square brackets for function scoping
% use elementwise operators ./ .^ when dealing with non-scalars
% since none of the vector lengths match, none of this will work anyway
1/((f)^2) = -2.0 log[((epsilon/D)/3.7) + ((2.51/Re*((f)^2)))];
% the loop structure is never closed
Given the state of this code, I'm not sure what it's even supposed to be doing.
EDIT: I'm guessing you're trying to solve the equation. You could do that a few ways, but you could also use existing works:
If nothing else, you can look at how they solve the equation.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeFoundation and Custom Domains についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by