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에 대해 자세히 알아보기

태그

질문:

2016년 8월 30일

편집:

2016년 8월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by