Combine output from for loop into one long vecor, then put that row into a cell.

1 次查看(过去 30 天)
Hi all,
I have this code, and it works how I would like for the first row, but I am having trouble generalizing it.
y = randi(10,10);
out = [];
m = sparse(y);
for j1 = 1:N
y1 = (j1-1) * ones(1, m(1,j1));
out = [out y1];
end
Thanks in advance.

采纳的回答

Star Strider
Star Strider 2015-8-20
Not certain I understand what you want, but if you want ‘out’ to be a cell array, just address it that way:
out{j1} = [out y1];
  12 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by