Too many input arguments error
1 次查看(过去 30 天)
显示 更早的评论
set(get(gca,'children'),'cdata',squeeze(Img(:,:,S,:),ImgSg(:,:,Si,:),ImgCr(:,:,S1,:)))
If I don't put ImgSg(:,:,Si,:),ImgCr(:,:,S1,:) then it's ok. But why are they too many input arguments?
0 个评论
回答(2 个)
Jan
2018-1-15
编辑:Jan
2018-1-15
The error message concerns squeeze:
A = Img(:,:,S,:)
B = ImgSg(:,:,Si,:);
C = ImgCr(:,:,S1,:);
X = squeeze(A, B, C) % <== 3 inputs, but SQUEEZE takes 1 only
Maybe you want:
squeeze([Img(:,:,S,:), ImgSg(:,:,Si,:), ImgCr(:,:,S1,:)])
or
squeeze(Img(:, :, [S, Si, S1], :))
But then the produced array is 4D and CData is a matrix usually.
0 个评论
Rik
2018-1-15
I would assume this syntax sets the cdata property of all the children to the same image. If you want to do multiple things, use a loop or repeated code. Or even better: get handles to the objects you are interested in, instead of relying on a specific number and order of children, as this is very prone to change (execution order or another Matlab release).
kids=get(gca,'children');
set(kids(1),'cdata',squeeze(Img(:,:,S,:))
set(kids(2),'cdata',ImgSg(:,:,Si,:))
set(kids(3),'cdata',ImgCr(:,:,S1,:))
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!