tags:

views:

32

answers:

1
>> padColor = [1 1 1];        %# RGB triple for pad color
padColor = reshape(padColor,1,1,3);  
>> padColor

padColor(:,:,1) =

     1


padColor(:,:,2) =

     1


padColor(:,:,3) =

     1

What does padColor(:,:,1) mean here?

+2  A: 

After reshaping, padColor is a 1-by-1-by-3 array. Since the size of the first two dimensions is 1, padColor(:,:,1), which means padColor("all","all",1) is equivalent to padColor(1,1,1). In other words, padColor(:,:,1) is the element you find in the first row, first column, first 'z-slice' of padArray.

Jonas
How can a 1-1-1 array be reshaped into a 1-1-3 array?Or more generally,into a m-n-k array?
Your original array is not 1-by-1-by-1; it's 1-by-3.
Steve Eddins