Reading data in cell arrays help

조회 수: 1 (최근 30일)
Albert Rey Ruelan
Albert Rey Ruelan 2017년 7월 30일
답변: Star Strider 2017년 7월 30일
Hi There was this line in a program code.
for k = 1:9
[i,j] = ind2sub([3,3],k);
Output(:,:,indx+k) = AccessImageDiff{row,col}(i:end-3+i,j:end-3+j);
end
Now my problem is how do i read this line? Can somebody teach me on how to read this specific line
  • Output(:,:,indx+k) = AccessImageDiff{row,col}(i:end-3+i,j:end-3+j);*
i know that it is accessing a cell array and manipulating its data but what i am confused about is the (i:end-3+i,j:end-3+j) part.
1.what does ":" mean?
2.what does "end" mean? It didn't use end as a variable.
Thanks in advance
There's this tutorial about accessing data in cell arrays but it doesn't really answer my question https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html

채택된 답변

Star Strider
Star Strider 2017년 7월 30일
‘... what i am confused about is the (i:end-3+i,j:end-3+j) part.’
Here, end is the size of the array in that dimension. See the documentation on end (link) for a full description, specifically:
  • The end function also serves as the last index in an indexing expression. In that context, end is the same as size(X,k) when used as part of the kth index into array X. Examples of this use are X(3:end) to select the third through final elements of the array, and X(1,1:2:end-1) to select all even elements of the first row, excluding the last element. When using end to grow an array, as in X(end+1)=5, make sure X exists first.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by