One way to do this is to write a class instead of a function. Below is a very simple class that you can extend as much as you want. This requires that you have divided two steps in its function into two functions are called runFirstStep, and runSecondStepin my example.
You run it like
obj = myAwesomeClass;
finalResults = obj.run(inputData); %
The intermediate result is stored in obj.intermediateResults, so if you call again run, the first step is automatically omitted.
, get intermediateResults. set , , get ( ) , , .
classdef myAwesomeClass<handle
properties
intermediateResults
end
methods
function finalResults = run(obj,inputData)
%
%
%
if isempty(obj.intermediateResults)
obj.intermediateResults = runFirstStep(inputData);
end
%
finalResults = runSecondStep(obj.intermediateResults);
end
end
end
, finalResults , set/get , plot, . , , .