This example shows how to use the output of one MATLAB® function as an input to another.
www.mathworks.com