matlab error Too many outputs requested. Most likely cause is missing [] around left hand side that has a comma separated list expansion

7 views (last 30 days)
Here is my code
for iii=1:num_patch
%lims=0;
flag=0;
for jjj=1:numel(cellsrc)
if(iii== cellsrc(jjj))
flag=1;
end
end
if(flag==0)
if(lim<=len)
im = hcell{(t==iii)};
x={}; % empty cell which will consist all blocks
dct_img=blkproc(im,[8,8],@dct2);% DCT of image using 8X8 block
m=dct_img; % Sorce image in which watermark will be inserted
temp={};
[values,cell1,R,C]=segmentImg1(m,8,8);
x=cell1;
k=0;
blockcapacity=R*C;
lims=1;
while(lim<=len)
k=k+1;
kx=(x{k}); % Extracting block into kx for processing
for i=1:8 % To address row of block
for j=1:8 % To adress column of block
if (i==8) && (j==8)% Eligiblity condition to insert watremark
% i=1 and j=1 - means embedding element in first bit of every block
kx(i,j)=rr(lim);
end
end
end
x{k}=kx; kx=[];
lim=lim+1;
lims=lims+1;
if(lims>blockcapacity)
break;
end
end
x=desegment(x,48,48);
x=(blkproc(x,[8 8],@idct2));
hcell{(t==iii)}=x;
end
end
end
Here am dividing an image into blocks of 48*48 size, total image size is 144*144. Am trying to embed the data into this block using dct. when am trying to embed lengthier data, at the 17th block it showing error like,
Too many outputs requested. Most likely cause is missing [] around left hand side that has a comma separated list expansion.
Error in main (line 134)
im = hcell{(t==iii)}; please help me as soon as possible.

Answers (1)

Stephen23
Stephen23 on 20 Jun 2016
Edited: Stephen23 on 20 Jun 2016
When t==iii has two or more true values, then this code
hcell{(t==iii)}
returns multiple values in a comma separated list. Note that you can try this yourself:
>> C = {1,2,3};
>> C{[false,false,true]} % only one true index -> one output
ans = 3
>> C{[true,false,true]} % two true values -> comma separated list
ans = 1
ans = 3
>> out = C{[true,false,true]} % try this!
However you only wrote one output variable, so there is a mismatch between the number of items in this comma separated list and the number of output arguments. Thus the error. To resolve this you could:
  1. accept all outputs by using hcell(t==iii) instead.
  2. handle the multiple matches (e.g. throw an error).
  3. fix the indexing to ensure that there is only one true index.
  4. capture the comma separated list using multiple output arguments:
[val1,val3] = C{[true,false,true]}
  3 Comments
ANJU  PS
ANJU PS on 20 Jun 2016
i want to get all the values inside that 48*48 block. If am omitting {} means it wouldnt able to get those values
Stephen23
Stephen23 on 20 Jun 2016
@ANJU PS: then find out why the seventeenth block causes this error, and fix it. Use the debugging tools to help you.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!