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 Kommentare

Stelios Fanourakis
Stelios Fanourakis am 12 Dez. 2017
The error comes to the line of Img=ImgAx;
which is completely unfair
Stephen23
Stephen23 am 12 Dez. 2017
@Stelios Fanourakis: how are you calling the function?
Stelios Fanourakis
Stelios Fanourakis am 12 Dez. 2017
Bearbeitet: Stelios Fanourakis am 12 Dez. 2017
@AxialView. It says it at the top
Stephen23
Stephen23 am 12 Dez. 2017
Bearbeitet: Stephen23 am 12 Dez. 2017
@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 am 12 Dez. 2017
This is the line code where I call the function AxialView:
VAxBtnhand = uicontrol('Style', 'pushbutton','Position', VAxBtn_Pos,'String','A', 'FontSize', BtnSz, 'Callback' , @AxialView);

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Stephen23
Stephen23 am 12 Dez. 2017
Bearbeitet: Stephen23 am 12 Dez. 2017

0 Stimmen

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.

Kategorien

Mehr zu Just for fun finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 12 Dez. 2017

Bearbeitet:

am 12 Dez. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by