Run for 100 times (loops) and save each result of run into a single matrix in MATLAB

Here a simple example: You want to run 100x times of this function, y=2i, where i is integer values (0 until 100) and you want to save each y into a single matrix (named as y1), you can write as follow:

for i=1:100 % 100 times of loops 
y=2*i % our function
y1(i,:)=y % each y will save on a single column in the matrix end

Be the first to comment

Leave a Reply

Your email address will not be published.