Too many input arguments error

1 回表示 (過去 30 日間)
Stelios Fanourakis
Stelios Fanourakis 2018 年 1 月 15 日
編集済み: Jan 2018 年 1 月 15 日
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?

回答 (2 件)

Jan
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.

Rik
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,:))

カテゴリ

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