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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by