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
end

About zulkarnainh

I was born in Melaka (1987), holds the degree in B.Eng.(2010), M.Eng (2012) and Ph.D. (2016) in Civil Engineering at Universiti Teknologi Malaysia. I have been the UniMAP since 2016 and currently serving as Senior Lecturer. Feel free to contact me if you are interested to collaborate or pursuit a study (Master or Ph.D.) with me. Thank you!
This entry was posted in Code and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *