How do I make a cell of cells in a for loop?
Show older comments
Here is the code I am running, I need an explanation on why this doesn't work and any suggestions on how to fix it. Thank you.
for k = 1:1:Ni
for bt = 1:1:(Lt/2)
omt1(bt,:)={xtu(2*bt-1,1),ptu(2*bt-1,k),ztu(2*bt-1,1),xtu(2*bt,1),ptu(2*bt,k),ztu(2*bt,1)};
end
end
xtu is a 202 x 1 column vector, ptu is a 202 x 8 matrix and ztu is a 202 x 1 vector. I take the even and odd entries to make the cell of 101 rows and 6 columns as seen in the for loop. Ni is an arbitrary input but let it be 8, Lt is equal to 202, as such bt = 1:1:101, omt1(bt,:) produces the last loop (k = 8) with omt1 being a cell made up of 101 rows x 6 cells.
What I want is for omt1 to be a cell made up of these 8 101 x 6 cells and I am stuck on this. Putting the : in omt1 as k so that I get a cell of 8 columns, each column being a cell of 101 x 6 does not work, why? I think it is because I have not said explicitly that omt1 is to be a cell of cells. At the moment it is just a cell of 101 x 6. How can this be done to put k across grouped as a cell? Thank you.
Accepted Answer
More Answers (0)
Categories
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!