From: Nanda on
Hi,

I've spent days gathering info on GUI's on the internet and in Matlab Help, watching instruction movies and studying example GUI's and I just don't get why I get this error (see Subject). Is there someone who can help me, please? I've indicated where the error occurs, because the first lines of code work fine.

Thanks so much in advance!
-Nanda

handles = [];
mFilename=[];
mSlices=[];
mXCoord=[];
mYCoord=[];
mZCoord=[];

mTotalVolume = [];
% Used functions from other m-files
VolRead = '';
VolCalc = '';
ContourBodyPlot= '';

% Construct the figure
f = figure('Visible','off','Position',[360,500,450,285]);
handles=guihandles(f);
% Construct the components
handles.hFilename = uicontrol('Style','edit','String','Select a file','Position'...
,[35,220,100,25],'Callback',{@fileDisplayText_Callback});
handles.hBrowse = uicontrol('Style','pushbutton','String','Browse...','Position'...
,[300,220,70,25],'Callback',{@browseButton_Callback});
handles.hFigureOn = uicontrol('Style','checkbox','String','Show contour figure',...
'Position',[35,50,200,40],'Callback',{@showFigure_Callback});
handles.hCalculate = uicontrol('Style','pushbutton','String','Calculate',...
'Position',[300,50,100,40],'Callback',{@calculateButton_Callback});

% Alignment of the components
align([handles.hBrowse,handles.hCalculate,handles.hFilename,...
handles.hFigureOn],'None','None');
prepareLayout(f);

% Show GUI
movegui(f,'center');
set(f,'Visible','on');

browseButton_Callback();

%% Programming of the buttons
% 'Browse' button
function browseButton_Callback(hObject1,eventdata)
filespec = {'*.vol','Contour Volume File (*.vol)'};
[Filename,Pathname]=uigetfile(filespec,'Pick a file');
mFilename = Filename;
fileDisplayText_Callback();
end
%----------------------------------------------------------------------
% Display filename
function fileDisplayText_Callback(hObject2,eventdata)
set(handles.hFilename,'String',mFilename);
end
%--------------------------------------------------------------------------
function calculateButton_Callback(hObject3,eventdata)
mFilename=get(handles.hFilename,'String');
% Obtain info from .vol file
%% THIS IS THE LINE WHERE THE ERROR OCCURS, ONLY AFTER USING THE BUTTON OF COURSE %%
[mSlices,mXCoord,mYCoord,mZCoord]=VolRead(mFilename);
% Calculating volume
mSlices=str2double(get(handles.mSlices,'String'));
mXCoord=str2double(get(handles.mXCoord,'String'));
mYCoord=str2double(get(handles.mYCoord,'String'));
mZCoord=str2double(get(handles.mZCoord,'String'));
[mTotalVolume] = VolCalc(mSlices,mXCoord,mYCoord,mZCoord);
end
end
From: Steven_Lord on


"Nanda " <nvanderstap(a)neurosurgery.ufl.edu> wrote in message
news:i39slp$6ke$1(a)fred.mathworks.com...
> Hi,
>
> I've spent days gathering info on GUI's on the internet and in Matlab
> Help, watching instruction movies and studying example GUI's and I just
> don't get why I get this error (see Subject). Is there someone who can
> help me, please? I've indicated where the error occurs, because the first
> lines of code work fine.
>
> Thanks so much in advance!
> -Nanda
>
> handles = []; mFilename=[]; mSlices=[];
> mXCoord=[];
> mYCoord=[];
> mZCoord=[];
>
> mTotalVolume = []; % Used functions from other m-files
> VolRead = '';

So this says VolRead is a variable ...

*snip*

> function calculateButton_Callback(hObject3,eventdata)
> mFilename=get(handles.hFilename,'String');
> % Obtain info from .vol file
> %% THIS IS THE LINE WHERE THE ERROR OCCURS, ONLY AFTER USING THE BUTTON OF
> COURSE %%
> [mSlices,mXCoord,mYCoord,mZCoord]=VolRead(mFilename);

and since this is a nested function, this line of code is interpreted not as
a function call with 4 outputs but as an attempt to index into the VolRead
variable from the workspace in which this function is nested, and as MATLAB
(correctly) indicated, indexing like this cannot return multiple outputs.

Don't indicate that VolRead is a variable and then try to use it as a
function -- that will not work. Use VolRead as a function or use VolRead as
a variable, you can't do both.

*snip*

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Jan Simon on
Dear Nanda,

> I've indicated where the error occurs, because the first lines of code work fine.

Is "cannot yield multiple results" the original error message? If not, please post the exact message.
The line number should be displayed in the command window, when the error appears.

> mFilename=get(handles.hFilename,'String');
> % Obtain info from .vol file
> %% THIS IS THE LINE WHERE THE ERROR OCCURS, ONLY AFTER USING THE BUTTON OF COURSE %%
> [mSlices,mXCoord,mYCoord,mZCoord]=VolRead(mFilename);

Which is the failing line? The "[mSlice ..." line? Then set a break point in the debugger in this line and run VolRead from the command line manually. Now inspect how many outputs are returned by VolRead.

Kind regards, Jan