index an array with arrays
이전 댓글 표시
I have two index arrays i1 and i2 and a data array data.
I want to set the areas of data in the following way:
data([i1(1):i2(1), i1(2):i2(2)]) = ... % and so on
Is there a way to do that fast without loops? It can be achieved via
for i=1:length(d1)
data(d1(i):d2(i)) = 1.0;
end
댓글 수: 3
Kevin Phung
2019년 3월 29일
can you be more clear in what you are trying to do? maybe give an example
James Tursa
2019년 3월 29일
How many dimensions does "data" have? Could that vary?
Christian Hufnagel
2019년 3월 29일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!