You define an array of cells and store the desired variable in it.
intermResults = cell(1,n);
for j = 1:n; %n is a user input
intermResults{j} = P*(1+i)^j; % each of these calculation I want to save
end
Then you can access the xx value:
desiredIntermResult = intermResults{xx}
Btw. I did not know that MATLAB supports the ++ operator.
This is not true. I modified the code to match Matlab syntax - Jonas
source
share