On 11/20/2014 9:44 AM, Jim wrote:
> I have a 6 dimensional matrix with dimensions 16x20x22x6x3x13. I
> identified specific elements of that matrix with the following:
> y = find(spec_neg(:,:,:,:,:,1) ~= 0);
> Since y is now the indices of the spec_neg and I would like these in
> matrix subscript form, I determined the subscripts by doing the following:
> [i,j,k,l,m,n] = ind2sub([16,20,22,6,3,13],y);
> and then concatenated these subscripts into matrix form:
> y_ind = cat(2,i,j);
> y_ind = cat(2,y_ind,k);
> y_ind = cat(2,y_ind,l);
> y_ind = cat(2,y_ind,m);
> y_ind = cat(2,y_ind,n);
>
> I want to obtain the values of spec_neg that correspond to the subscript
> values of y_ind but when I do the following:
> spec_neg(y_ind)
> I get all zeros so that is obviously not the values in y.
>
> What am I doing wrong?
size(spec_neg(:,:,:,:,:,1)) ~= [16,20,22,6,3,13] but [16,20,22,6,3,1]
since you reduced the last dimension to only one in the input to the
find(). (BTW, find(...)~=0 is same as find(...), the ~=0 is superfluous).
--
> I have a 6 dimensional matrix with dimensions 16x20x22x6x3x13. I
> identified specific elements of that matrix with the following:
> y = find(spec_neg(:,:,:,:,:,1) ~= 0);
> Since y is now the indices of the spec_neg and I would like these in
> matrix subscript form, I determined the subscripts by doing the following:
> [i,j,k,l,m,n] = ind2sub([16,20,22,6,3,13],y);
> and then concatenated these subscripts into matrix form:
> y_ind = cat(2,i,j);
> y_ind = cat(2,y_ind,k);
> y_ind = cat(2,y_ind,l);
> y_ind = cat(2,y_ind,m);
> y_ind = cat(2,y_ind,n);
>
> I want to obtain the values of spec_neg that correspond to the subscript
> values of y_ind but when I do the following:
> spec_neg(y_ind)
> I get all zeros so that is obviously not the values in y.
>
> What am I doing wrong?
size(spec_neg(:,:,:,:,:,1)) ~= [16,20,22,6,3,13] but [16,20,22,6,3,1]
since you reduced the last dimension to only one in the input to the
find(). (BTW, find(...)~=0 is same as find(...), the ~=0 is superfluous).
--