[Solved] Reading output of a function as an input in another function [closed]


The optimization algorithm that I was using was GA(Genetic Algorithm). I wrote this function in order to get what I wanted:

function [zz,fvalzz] = secstep(z,NVARS)
 [zz,fvalzz]=ga(@secfun,NVARS);

function ff = secfun(zz)
 y=.5*exp(-35*10^12*(t-2e-6).^2).*cos(2*pi*5e6*(t-2e-6)+0);

sigme2=zz(1)* exp(-z(1)*10^12*(t-zz(2)*10^-6).^2).*cos(2*pi*z(3)*10^6*(t-zz(2)*10^-6)+z(4)); %z vector has been calculated from another function.
NN=length(y);   
ff =sum((y-sigme2).^2)/NN;
end
end

solved Reading output of a function as an input in another function [closed]