Not enough input arguments

조회 수: 2 (최근 30일)
Stelios Fanourakis
Stelios Fanourakis 2017년 12월 12일
편집: Stephen23 2017년 12월 12일
I believe to properly have set up the function. I don't think to miss anything, but still keeps giving me the error of not enough input arguments.
function AxialView(object,eventdata,ImgAx,S_s,S_c,S,S_a,sno,sno_a,Rmin,Rmax,shand,stxthand)
if view == 'S'
S_s = S;
elseif view == 'C'
S_c = S;
end
view == 'A';
Img = ImgAx;
S = S_a;
sno = sno_a;
cla(hdl_im);
hdl_im = axes('position',[0,0.2,1,0.8]);
imshow(squeeze(Img(:,:,S,:)), [Rmin Rmax])
if sno > 1
shand = uicontrol('Style', 'slider','Min',1,'Max',sno,'Value',S,'SliderStep',[1/(sno-1) 10/(sno-1)],'Position', S_Pos,'Callback', {@SliceSlider, Img});
stxthand = uicontrol('Style', 'text','Position', Stxt_Pos,'String',sprintf('Slice# %d / %d',S, sno), 'BackgroundColor', [0.8 0.8 0.8], 'FontSize', SFntSz);
else
stxthand = uicontrol('Style', 'text','Position', Stxt_Pos,'String','2D image', 'BackgroundColor', [0.8 0.8 0.8], 'FontSize', SFntSz);
end
caxis([Rmin Rmax])
if sno > 1
set(stxthand, 'String', sprintf('Slice# %d / %d',S, sno));
else
set(stxthand, 'String', '2D image');
end
set(get(gca,'children'),'cdata',squeeze(Img(:,:,S,:)))
set (gcf, 'ButtonDownFcn', @mouseClick);
set(get(gca,'Children'),'ButtonDownFcn', @mouseClick);
end
  댓글 수: 5
Stephen23
Stephen23 2017년 12월 12일
편집: Stephen23 2017년 12월 12일
@Stelios Fanourakis: at the top you show us how you define the function, but not how it is called. I ask you to please show us how you are calling the function.
Basic ways of calling functions are explained in the introductory tutorials, which are highly recommended for all beginners:
Stelios Fanourakis
Stelios Fanourakis 2017년 12월 12일
This is the line code where I call the function AxialView:
VAxBtnhand = uicontrol('Style', 'pushbutton','Position', VAxBtn_Pos,'String','A', 'FontSize', BtnSz, 'Callback' , @AxialView);

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

답변 (1개)

Stephen23
Stephen23 2017년 12월 12일
편집: Stephen23 2017년 12월 12일
Your comment shows that you have provided the function handle as a callback function to some GUI object. When you read the documentation for callback functions, it will inform you that by default only two arguments are provided to the callback function, which are called the source and event (commonly named src and evt inside the function definition).
Your function requires more than two input arguments - do you see the problem now?
If you wish to pass additional arguments then you will have to either:
  • Read the section "Passing Additional Input Arguments" in the documentation that I linked to above.
  • Use nested functions.
MATLAB does not just magically fill all of those input arguments with values.

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by