Help Storing Values in a Matrix For Loop
显示 更早的评论
I know this questions has been asked numerous times, but I haven't found an answer for this case. It is hard to explain so, I will put the code in to hopefully help better understand the problem.
red_matrix=zeros(5)
for ii=2
matrix_sort=sort(time(:))
n=[2:25]
min_t(ii)=matrix_sort(n(ii));%new min t after initialization
[row(ii),col(ii)]=find(time==min_t(ii));%finding block address
red_matrix(row(ii),col(ii))=1
so after every loop, there is a different column and row that needs to be replaced with a "1" in the red_matrix. The problem is, that I need to keep the old 1 value also. I've tried everything I can think of but it keeps resetting the matrix after every loop.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!