MATLAB: How to use result of one function for another function?

calling functions in functionsfunctions

i want to use the results of one function for another function within the same or different file…plese help me how to do it….
sample program:
function [ y ] = heatsource( x1, x2 )
function [ x1, x2] = result( c, d )
c=2;
d=3;
x1=c+d;
x2=c-d;
end
y=x1+x2;
y
end

Best Answer

mainscript.m
c=2; d=3;
[ x1, x2] = result( c, d )
[ y ] = heatsource( x1, x2 )
result.m
function [ x1, x2] = result( c, d )
x1=c+d;
x2=c-d;
heatsource.m
function [ y ] = heatsource( x1, x2 )
y=x1+x2;