??? Assignment has more non-singleton rhs dimensions than non-singleton subscripts

조회 수: 11 (최근 30일)
% my array declaration
imgarr=zeros([5,3,nFrames]);
% Create topleft quantized image
[img1,map] = rgb2ind(tl,64);
% color planes for topleft image
tl_rPlane = reshape(map(img1+1,1),size(img1)); % Red color plane for image
tl_gPlane = reshape(map(img1+1,2),size(img1)); % green color plane
tl_bPlane = reshape(map(img1+1,3),size(img1)); % blue color plane
imgarr(1,1,k)=imhist(tl_rPlane); % storing histograms for the 3 color planes to the kth dimension of the array..
imgarr(1,2,k)=imhist(tl_gPlane);
imgarr(1,3,k)=imhist(tl_bPlane);
my error:
??? Assignment has more non-singleton rhs dimensions than
non-singleton subscripts
Error in ==> modified at 42
imgarr(1,1,k)=imhist(tl_rPlane);
i need to store the histogram values of the three color planes to the array please do help me...im totally a newcomer to matlab...
[EDITED, Jan, code formatted]

채택된 답변

Jan
Jan 2012년 12월 28일
imhist replies a vector, but imgarr(1,1,k) is a scalar, if k is scalar. Perhaps you want imgarr to be a cell array:
imgarr = cell(5,3,nFrames);
...
imgarr{1,1,k} = imhist(tl_rPlane);
You can store only vectors of the same length in an numerical array, but in a cell array all elements can have different type and size. As a drawback, it is much harder to perform calculations with cell arrays, of course.
  댓글 수: 1
soumya
soumya 2012년 12월 31일
Thank u boss....i was a bit confused with cell array and numeric array concepts.... :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by