How can I store nested for loop values to a cell array?

36 views (last 30 days)
I am using a nested for loop. Loop executed values are being stored in cell array but for the first row its working well but from the secong row the last cell value of first row is being repeated . how to solve this ?
  1 Comment
Adam on 26 Feb 2019
You haven't shown any code so it's rather difficult to guess!

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 26 Feb 2019
Edited: Adam Danz on 26 Feb 2019
Here's a general sketch of how to store data in a cell array within two nested for-loops. If there is something more specific you're looking for, please add some details.
myCell = cell(n,m);
for i = 1:n
for j = 1:m
myCell{i,j} = myFunction(data);

Sign in to comment.

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!