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

4 次查看(过去 30 天)
% 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 CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by