lets say you have some function
x = foo(alpha, beta);
and you want to test the function for different alpha values while saving the different x values with a name associated to the different alpha values.
For example if alpha = 1:1:10;
then then i would like to save x_1 , x_2 ,........,x_9 , x_10 as separate results
I’ve tried running different loops and such but I can’t figure out how to keep the x values from being replaced
There are several ways to do this
For example, if you want to save results to disk, you can run
If, instead, you want to store all outputs, so that you can plot, for example, you can store them in an array
Note that the above assumes that the output of
foois scalar. If the output is always am-by-narray, you initializexaszeros(m,n,length(alpha)), and assignx(:,:,ii)each loop. If the output is arrays of different size, you initializexas a cell array, asx = cell(size(alpha)), and assign the output offootox{ii}.