Filter löschen
Filter löschen

How to call a function properly.

2 Ansichten (letzte 30 Tage)
Yianni
Yianni am 8 Nov. 2014
Kommentiert: Star Strider am 8 Nov. 2014
I want to take a function file and call it into my script. I have this function:
function ff = fCW()
F = @(f,Re) 2*log10(Re*sqrt(f))-0.8-(1/sqrt(f));
Re = linspace(1e4,1e7,6);
ff = zeros(size(Re));
for k = 1:length(Re)
ff(k) = fzero( @(f) F(f,Re(k)), 0.05 );
end
end
And I want to call it into this script file:
clear all, close all
Re1=linspace(1e+4,1e+7,6); NRe1=length(Re1);
fB = zeros(size(Re1)); fSJ = fB;
for i=1:NRe1
fSJ(i)=0.25/(log10(5.74/Re1(i)^0.9))^2;
fB(i)=0.3164/Re1(i)^0.25;
end
I want to plot(Re, fCW, Re1, fSJ, Re1, fB).
Is there an easy way to do this?

Akzeptierte Antwort

Star Strider
Star Strider am 8 Nov. 2014
Did you run it as you posted? Did it work?
If all the relevant vector pairs have the same lengths: (Re,fCW), (Re1,fSJ), (Re1,fB), the plot call should work as you wrote it.
  2 Kommentare
Yianni
Yianni am 8 Nov. 2014
It works thank you!
Star Strider
Star Strider am 8 Nov. 2014
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Argument Definitions 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