Not enough input arguments
2 次查看(过去 30 天)
显示 更早的评论
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
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:
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!