How do you append to a matrix within a for loop?
375 次查看(过去 30 天)
显示 更早的评论
Hi, I am using a for loop to process data (this part works fine). What I need to do is take the matrix (A) and after each loop update A to create one matrix. For instance, in the image below A is produced on the first loop, during loop 2 A "grows" to include the data from loop 1 and the data from loop 2, and so on.
Loop 1 produces a matrix, on the next iteration I need to append to this matrix the results of that loop, and so on until all of the data is processed.
It should be noted that the number of rows on each loop is unknown. However, the number of columns is fixed to 7.
Any ideas would be greatly appreciated please.
0 个评论
采纳的回答
更多回答(2 个)
SRIAKILAN S A
2023-2-21
% make an empty array
% the main command is end+1
N=[];
for i=0:10
x=i*i;
N(end+1)=[x]
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!