Error: Function definition not supported in this context. Create functions in code file.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function FixedPointIteration
%Fixed Point Iteration
Re=p*V*D/mu can be rewritten as Re= (1/mu)*P*V*D
D=.005;
V=40;
p=1.23;
mu=1.79*10*-5;
e=.0015;
function of Re;
Re=p*V*D/mu;%reynolds numbere quation
g=@(x)(1/sqrt(x)+2*log(e/(3.7*D)+2.51/(Re*sqrt(x))));
%x = f(x)
syms 'x'
f=@(x)(-1./(2*log(e/(3.7*D)+2.51/(Re*sqrt(x))))).^2;
x=.08;
i=1;
while abs(g(x))> 1e-9
x=f(x);
end
fprintf('Root found: %.10f\n'x)
fprintf('Function value at root %E\n',g(x))
0 commentaires
Réponses (1)
Walter Roberson
le 13 Déc 2020
Modifié(e) : Walter Roberson
le 13 Déc 2020
function of Re;
Wrong syntax for declaring a function.
Missing a % if it is intended to be a comment.
Re=p*V*D/mu can be rewritten as Re= (1/mu)*P*V*D
missing a % between the code and the comments
1 commentaire
Image Analyst
le 13 Déc 2020
function x = FixedPointIteration()
% Fixed Point Iteration
D=.005;
V=40;
p=1.23;
mu=1.79*10*-5;
e=.0015;
% Define the Re function:
% Re=p*V*D/mu can be rewritten as Re= (1/mu)*P*V*D if you'd rather.
Re=p*V*D/mu; % Reynolds number equation
% etc.
Voir également
Catégories
En savoir plus sur Entering Commands 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!