Saving outputs in workspace
36 views (last 30 days)
More Answers (1)
Image Analyst on 21 Nov 2012
It's best not to do that. It's best to define a function and then have that function return output arguments which are then accepted and used by your main script or calling function
In function1.m or myscript1.m:
function function1() % Only used if it's a function, not if it's a script.
% Then (regardless if it's a function of a script), call it like this:
[out1 out2] = MyFunction(in1, in2, in3);
Then, in MyFunction, define it like this:
function [out1 out2] = MyFunction(in1, in2, in3)
% Code to create out1 and out2 from in1, in2, and in3
MyFunction can be inside function1.m if you're using a function. If the main routine is a script (no function keyword to start off the m-file), then you can't define MyFunction inside the "myscript.m" script m-file.
I suggest you read the documentation on how to use functions.