Parse error at '<': usage might be invalid MATLAB syntax
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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 commentaires
Ive J
le 26 Août 2021
Modifié(e) : Walter Roberson
le 27 Août 2021
what about learning MATLAB before using :) ?
mathworks.com/learn/tutorials/matlab-onramp.html
DGM
le 26 Août 2021
Modifié(e) : DGM
le 27 Août 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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Foundation and Custom Domains dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!