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

9 ビュー (過去 30 日間)
soumya
soumya 2012 年 12 月 28 日
% 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 Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by