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

2 Ansichten (letzte 30 Tage)
Arupratan Gupta
Arupratan Gupta am 26 Aug. 2021
Bearbeitet: Walter Roberson am 27 Aug. 2021
% 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 Kommentare
Ive J
Ive J am 26 Aug. 2021
Bearbeitet: Walter Roberson am 27 Aug. 2021
what about learning MATLAB before using :) ?
mathworks.com/learn/tutorials/matlab-onramp.html
DGM
DGM am 26 Aug. 2021
Bearbeitet: DGM am 27 Aug. 2021
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Foundation and Custom Domains finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by