MATLAB: How to return an individual matrix from a function that uses multiple

functionMATLABmatlab functionmatrixmatrix manipulation

I have a nested parent function that operates on multiple matrices using other functions. I then want to return individual matrixes to others. Ive listed toy code below as a general example of what im trying to do:
% id like to return these matrices in a wat so that i could assign them elsewhere like:
% g = fun(d)
function fun1 = fun(a, b,c,n)
for i = 1:1:lentgth (n)
d(i) = add(a(i),b(i));
e(i) = subtract(a(i),c(i));
f(i) = multiply(b(i),c(i));
end
end

Best Answer

On your code whatever you assign to fun1 would be returned. You can also do things like
function [d, e, f] = fun(a, b, c, n)
And then three matrices would be returned positionally.