How to combine two functions into a single expression?

There are two functions: function xa, function a. The output of function xa is the input to function a. How do I combine the two functions so that I don't have to enter in two separate functions?
function xa= ZvalueXA(FPave, Vavenew, Vstdnew, N)
xa=(FPave-Vavenew)/((Vstdnew)/(N.^0.5));
% function xa is the output and then is imputed into function a
% FPave, Vavenew, Vstdnew, N are imputed (experimental)values from the normal distribution plots at a certain temperature.
% FPave is the Flag Point Ave. Vavenew is the SOL Average V
% Vstdnew is the Standard Deviation of the Average V and N is the
% number of C
function a= ProbabilityPXnew(xa)
a= 1-0.5*erfc(-(xa)/sqrt(2));
% function a calculates the standard normal distribution plot using the calculate Zvalue.
... a(f(xa))

 Réponse acceptée

Wayne King
Wayne King le 22 Août 2012
Modifié(e) : Wayne King le 22 Août 2012
You can always write one function inside the other function as a "local" function
Ex:
function [out] = outerfunction(input)
tmp = innerfunction(input)
function [out] = innerfunction(input)
line 1
line 2
end
end
Otherwise if you have two functions on the path, then you can compose them:
mean(randn(100,1))

1 commentaire

is it possible to give it with example, i did not get that.
i need to write the integration like this integral consum( velocityy(x, distance_routeX, speed_routeX))
i need to put one function as input of another function and get the intergration .
my first function is this:
function [c] = consum(v)
load('elbilTesla'); % inserting the dataset
% initilizing the x_values and y_va;ues
x = speed_kmph;
y = consumption_Whpkm;
%curvfitting
p = polyfit(x,y,2);
c = polyval(p,v);
my second fuction is this :
function [v] = velocityy(x, distance_routeX, speed_routeX)
v= NaN;
if (x<min(distance_routeX))
disp('your selected dostance is out of range ');
elseif(x> max(distance_routeX))
disp('your selected dostance is out of range ');
else
v = spline(distance_routeX, speed_routeX,x);
end

Connectez-vous pour commenter.

Plus de réponses (1)

Passing input arguments:
>> a = ProbabilityPXnew( FPave, Vavenew, Vstdnew, N );
where
function a = ProbabilityPXnew( varargin )
xa = ZvalueXA( varargin{:} );
your_code
end
function xa = ZvalueXA( FPave, Vavenew, Vstdnew, N )
more_code
end

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by