GUI doesn't run M-file (error) while manually running (F5) this M-file doesn't give any problems.

I have made some quite complex m scripts which work fine when I run them next to each other. Now I want to make it easier to run (without switching between m-files) by using a GUI.
I have made some buttons which run a different m-file each.
  1. First I run a 'reset' script with a 'reset' button which runs a starting plot and defines some variables and matrices/arrays. With the assignin function I managed to put this variables in the Workspace so that I can use them for the other scripts. This works fine.
  2. Then I can include some variables in the GUI textbox which are included in the workspace as well, again with the assignin function. This works fine too.
  3. But then, with another button I want to run another m-file (which needs variables and a plot defined before). Then I get a lot of errors. However, when I run this m-file manually with F5, everthing works fine. What do I do wrong?
These are the errors I got (the sys variable is one of the variables I define in the GUI, and this is succesfully included in the workspace):
Undefined function or variable 'sys'.
Error in Holecheck (line 51)
if sys==1
Error in Interfacetest>pushbutton_add_Callback (line 165)
Holecheck
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Interfacetest (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Interfacetest('pushbutton_add_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Error using assignin
Too many output arguments.
Error in Interfacetest>popupmenu_system_Callback (line 135)
sys=assignin('base','sys',(get(hObject,'Value')))
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Interfacetest (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Interfacetest('popupmenu_system_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Error using evalin
Argument must contain a string.
Error in Interfacetest>popupmenu_system_Callback (line 135)
sys=evalin('base',(get(hObject,'Value')))
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Interfacetest (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Interfacetest('popupmenu_system_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

Answers (1)

You have
sys=assignin('base','sys',(get(hObject,'Value')))
However, assignin() does not return a value.
You have
sys=evalin('base',(get(hObject,'Value')))
however, get() of a uicontrol popup is always numeric, so you are asking to evalin('base', NUMERIC), which is not permitted syntax.
... I think you should look at
and

8 Comments

Thanks for your answer but I still don't get it. When I implement: sys=getappdata(hObject,'sys') It still doesn't work...
(sys is a very simple variable (from 1 to 6) which comes from a drop down menu in the GUI)
In the picture you can see my interface. The script behind is:
function varargout = Interfacetest(varargin)
% INTERFACETEST MATLAB code for Interfacetest.fig
% INTERFACETEST, by itself, creates a new INTERFACETEST or raises the existing
% singleton*.
%
% H = INTERFACETEST returns the handle to a new INTERFACETEST or the handle to
% the existing singleton*.
%
% INTERFACETEST('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in INTERFACETEST.M with the given input arguments.
%
% INTERFACETEST('Property','Value',...) creates a new INTERFACETEST or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Interfacetest_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Interfacetest_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Interfacetest
% Last Modified by GUIDE v2.5 20-Jul-2017 12:59:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Interfacetest_OpeningFcn, ...
'gui_OutputFcn', @Interfacetest_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Interfacetest is made visible.
function Interfacetest_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Interfacetest (see VARARGIN)
% Choose default command line output for Interfacetest
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Interfacetest wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Interfacetest_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function edit_holewidth_Callback(hObject, eventdata, handles)
% hObject handle to edit_holewidth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
assignin('base','holewidth',str2num(get(hObject,'String')))
% Hints: get(hObject,'String') returns contents of edit_holewidth as text
% str2double(get(hObject,'String')) returns contents of edit_holewidth as a double
% --- Executes during object creation, after setting all properties.
function edit_holewidth_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_holewidth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_holeheight_Callback(hObject, eventdata, handles)
% hObject handle to edit_holeheight (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
assignin('base','holeheight',str2num(get(hObject,'String')))
% Hints: get(hObject,'String') returns contents of edit_holeheight as text
% str2double(get(hObject,'String')) returns contents of edit_holeheight as a double
% --- Executes during object creation, after setting all properties.
function edit_holeheight_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_holeheight (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton_reset.
function pushbutton_reset_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
MainAlgorithm
% --- Executes on selection change in popupmenu_system.
function popupmenu_system_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_system (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
sys=getappdata(handles.popupmenu_system,'sys');
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_system contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_system
% --- Executes during object creation, after setting all properties.
function popupmenu_system_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_system (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton_determine.
function pushbutton_determine_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_determine (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton_add.
function pushbutton_add_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_add (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Holecheck
% --- Executes on button press in pushbutton_data.
function pushbutton_data_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
  1. I first push the reset button which runs this code:
%Defining plot and read variables from excel
clear all
mapOriginal=im2bw(imread('1278.bmp')); % input map read from a bmp file. for new maps write the file name here
figure(1)
imshow(mapOriginal);
set(gca,'YDir','normal');
resolutionX=160;
resolutionY=189;
filename='Mainprogramsheet.xlsx';
sheet=1;
x1Range='I3:J14';
TRUNK=xlsread(filename,sheet,x1Range);
assignin('base','TRUNK',TRUNK)
hold on
plot(TRUNK(:,1),TRUNK(:,2),'bo')
%clear variables
Cable{size(TRUNK,1)}=[];
Grey{size(TRUNK,1)}=[];
Black{size(TRUNK,1)}=[];
HVACS{size(TRUNK,1)}=[];
HVACE{size(TRUNK,1)}=[];
HVACR{size(TRUNK,1)}=[];
POT{size(TRUNK,1)}=[];
HPG=0;HPB=0;HPHS=0;HPHE=0;HPHR=0;HPPOT=0;
assignin('base','filename',filename)
assignin('base','sheet',sheet)
assignin('base','Cable',Cable)
assignin('base','Grey',Grey)
assignin('base','Black',Black)
assignin('base','HVACS',HVACS)
assignin('base','HVACE',HVACE)
assignin('base','HVACR',HVACR)
assignin('base','POT',POT)
assignin('base','HPG',HPG)
assignin('base','HPB',HPB)
assignin('base','HPHS',HPHS)
assignin('base','HPHE',HPHE)
assignin('base','HPHR',HPHR)
assignin('base','HPPOT',HPPOT)
  1. Then I cleared/set the variables and with the Addhole button I run the next script.
%define rectangle for plot
Xout=500;
Yout=500;
r=100;
Edge=r-cosd(45)*r;
X=Xout-2*Edge;
Y=Yout-2*Edge;
%make plot
HY=3
HX=6
n=1
figHandle = figure(2);
hold on
for k=0:HY-1
Hole(n)=k*(HX+2)+1;
subplot(HY+1,HX+2,Hole(n));
axis([-Edge Xout+Edge -Edge Yout+Edge])
rectangle('Position',[0 0 X Y])
rectangle('Position',[-Edge -Edge Xout Yout],'Curvature',[(2*r/X) (2*r/Y)])
title(['Hole ' num2str(n)])
n=n+1;
end
for k=(HY*(HX+2))+2:((HY+1)*(HX+2))-1
Hole(n)=k;
subplot(HY+1,HX+2,k);
axis([-Edge Xout+Edge -Edge Yout+Edge])
rectangle('Position',[0 0 X Y])
rectangle('Position',[-Edge -Edge Xout Yout],'Curvature',[(2*r/X) (2*r/Y)])
title(['Hole ' num2str(n)])
n=n+1;
end
for k=HY:-1:1
Hole(n)=k*(HX+2);
subplot(HY+1,HX+2,Hole(n));
axis([-Edge Xout+Edge -Edge Yout+Edge])
rectangle('Position',[0 0 X Y])
rectangle('Position',[-Edge -Edge Xout Yout],'Curvature',[(2*r/X) (2*r/Y)])
title(['Hole ' num2str(n)])
n=n+1;
end
sheet=1;
Range1='A19:B19';Range2='C19:D19';Range3='E19:F19';Range4='G19:H19';Range5='I19:J19';Range6='K19:L19';Range7='M19:N19';
%filling matrices. Each run, the dimensions of a new rectangle are added to
%the matrix of the defined system (with the interface drop down)
if sys==1
Cable{I}=[Cable{I}(1:end-1,:);holeheight,holewidth;0 0];
end
if sys==2
Grey{I}=[Grey{I}(1:end-1,:);holeheight,holewidth;0 0];
end
if sys==3
Black{I}=[Black{I}(1:end-1,:);holeheight,holewidth;0 0];
end
if sys==4
HVACS{I}=[HVACS{I}(1:end-1,:);holeheight,holewidth;0 0];
end
if sys==5
HVACE{I}=[HVACE{I}(1:end-1,:);holeheight,holewidth;0 0];
end
if sys==6
HVACR{I}=[HVACR{I}(1:end-1,:);holeheight,holewidth;0 0];
end
if sys==7
POT{I}=[POT{I}(1:end-1,:);holeheight,holewidth;0 0];
end
A=rectangle('Position',[0 Y-Cable{I}(1,2) 0 0]);
B=rectangle('Position',[0 0 0 0]);
%%Plotting all defined rectangles in figure.
%%Cable ladders
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XC(1,1)=0;
YC(1,1)=Y-Cable{I}(1,2);
if any(Cable{I}>0)
for i=1:size(Cable{I},1)-1
if Cable{I}(i,1)<=X
if Cable{I}(i,2)<=Y
if Cable{I}(i,1)<=(X-XC(i,1))
A=rectangle('Position',[XC(i,1) YC(i,1) Cable{I}(i,1) Cable{I}(i,2)],'FaceColor','Blue');
XC(i+1,1)=XC(i,1)+Cable{I}(i,1);
YC(i+1,1)=YC(i,1)-(Cable{I}(i,2)-Cable{I}(i+1,2));
elseif Cable{I}(i,2)<=min(YC(1:i,1))
XC(i,1)=0;
YC(i,1)=min(YC(1:i-1,1))-Cable{I}(i,2);
A=rectangle('Position',[XC(i,1) YC(i,1) Cable{I}(i,1) Cable{I}(i,2)],'FaceColor','Blue');
XC(i+1,1)=XC(i,1)+Cable{I}(i,1);
YC(i+1,1)=YC(i,1)+(Cable{I}(i,2)-Cable{I}(i+1,2));
else
disp(['Does not fit for hole ' num2str(I)])
I=I+1
run Holecheck
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
YC(end,:)=[];
end
%%Grey water lines
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XG=0;
YG=0;
for i=1:size(Grey{I},1)-1
if Grey{I}(i,1)<=X
if Grey{I}(i,2)<=Y
if Grey{I}(i,1)<=(X-XG(i,1))
B=rectangle('Position',[XG(i,1) YG(i,1) Grey{I}(i,1) Grey{I}(i,2)],'FaceColor',[0.38 0.20 0.07]);
XG(i+1,1)=XG(i,1)+Grey{I}(i,1);
YG(i+1,1)=YG(i,1);
HPG(i,1)=YG(i,1)+Grey{I}(i,2);
elseif Grey{I}(i,2)<=min(YC)-max(HPG)
XG(i,1)=0;
YG(i,1)=max(HPG);
B=rectangle('Position',[XG(i,1) YG(i,1) Grey{I}(i,1) Grey{I}(i,2)],'FaceColor',[0.38 0.20 0.07]);
XG(i+1,1)=XG(i,1)+Grey{I}(i,1);
YG(i+1,1)=YG(i,1);
HPG(i,1)=YG(i,1)+Grey{I}(i,2);
else
disp(['Does not fit for hole ' num2str(I)])
I=I+1
run Holecheck
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
%%Black water lines
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XB=0+XG(end,1);
YB=0+YG(end,1);
HPB=0+max(HPG);
for i=1:size(Black{I},1)-1
if Black{I}(i,1)<=X
if Black{I}(i,2)<=Y
if Black{I}(i,1)<=(X-XB(i,1))
B=rectangle('Position',[XB(i,1) YB(i,1) Black{I}(i,1) Black{I}(i,2)],'FaceColor','Black');
XB(i+1,1)=XB(i,1)+Black{I}(i,1);
YB(i+1,1)=YB(i,1);
HPB(end+1,1)=YB(i,1)+Black{I}(i,2);
elseif Black{I}(i,2)<=min(YC)-max(HPB)
XB(i,1)=0;
YB(i,1)=max(HPB);
B=rectangle('Position',[XB(i,1) YB(i,1) Black{I}(i,1) Black{I}(i,2)],'FaceColor','Black');
XB(i+1,1)=XB(i,1)+Black{I}(i,1);
YB(i+1,1)=YB(i,1);
HPB(end+1,1)=YB(i,1)+Black{I}(i,2);
else disp(['Does not fit for hole ' num2str(I)])
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
%%HVAC supply
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XHS=0+XB(end,1);
YHS=0+YB(end,1);
HPHS=0+max(max(HPG),max(HPB));
for i=1:size(HVACS{I},1)-1
if HVACS{I}(i,1)<=X
if HVACS{I}(i,2)<=Y
if HVACS{I}(i,1)<=(X-XHS(i,1))
B=rectangle('Position',[XHS(i,1) YHS(i,1) HVACS{I}(i,1) HVACS{I}(i,2)],'FaceColor',[0.80 0.60 0.80]);
XHS(i+1,1)=XHS(i,1)+HVACS{I}(i,1);
YHS(i+1,1)=YHS(i,1);
HPHS(end+1,1)=YHS(i,1)+HVACS{I}(i,2);
elseif HVACS{I}(i,2)<=min(YC(:,1))-max(HPHS)
XHS(i,1)=0;
YHS(i,1)=max(HPHS);
B=rectangle('Position',[XHS(i,1) YHS(i,1) HVACS{I}(i,1) HVACS{I}(i,2)],'FaceColor',[0.80 0.60 0.80]);
XHS(i+1,1)=XHS(i,1)+HVACS{I}(i,1);
YHS(i+1,1)=YHS(i,1);
HPHS(end+1,1)=YHS(i,1)+HVACS{I}(i,2);
else disp(['Does not fit for hole ' num2str(I)])
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
%%HVAC exhaust
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XHE=0+XHS(end,1);
YHE=0+YHS(end,1);
HPHE=0+max(max(max(HPG),max(HPB)),max(HPHS));
for i=1:size(HVACE{I},1)-1
if HVACE{I}(i,1)<=X
if HVACE{I}(i,2)<=Y
if HVACE{I}(i,1)<=(X-XHE(i,1))
B=rectangle('Position',[XHE(i,1) YHE(i,1) HVACE{I}(i,1) HVACE{I}(i,2)],'FaceColor',[0 0.20 0]);
XHE(i+1,1)=XHE(i,1)+HVACE{I}(i,1);
YHE(i+1,1)=YHE(i,1);
HPHE(end+1,1)=YHE(i,1)+HVACE{I}(i,2);
elseif HVACE{I}(i,2)<=min(YC(:,1))-max(HPHE)
XHE(i,1)=0;
YHE(i,1)=max(HPHE);
B=rectangle('Position',[XHE(i,1) YHE(i,1) HVACE{I}(i,1) HVACE{I}(i,2)],'FaceColor',[0 0.20 0]);
XHE(i+1,1)=XHE(i,1)+HVACE{I}(i,1);
YHE(i+1,1)=YHE(i,1);
HPHE(end+1,1)=YHE(i,1)+HVACE{I}(i,2);
else disp(['Does not fit for hole ' num2str(I)])
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
%%HVAC recirculation
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XHR=0+XHE(end,1);
YHR=0+YHE(end,1);
HPHR=0+max(max(max(HPG),max(HPB)),max(max(HPHS),max(HPHE)));
for i=1:size(HVACR{I},1)-1
if HVACR{I}(i,1)<=X
if HVACR{I}(i,2)<=Y
if HVACR{I}(i,1)<=(X-XHR(i,1))
B=rectangle('Position',[XHR(i,1) YHR(i,1) HVACR{I}(i,1) HVACR{I}(i,2)],'FaceColor','yellow');
XHR(i+1,1)=XHR(i,1)+HVACR{I}(i,1);
YHR(i+1,1)=YHR(i,1);
HPHR(end+1,1)=YHR(i,1)+HVACR{I}(i,2);
elseif HVACR{I}(i,2)<=min(YC(:,1))-max(HPHR)
XHR(i,1)=0;
YHR(i,1)=max(HPHR);
B=rectangle('Position',[XHR(i,1) YHR(i,1) HVACR{I}(i,1) HVACR{I}(i,2)],'FaceColor','yellow');
XHR(i+1,1)=XHR(i,1)+HVACR{I}(i,1);
YHR(i+1,1)=YHR(i,1);
HPHR(end+1,1)=YHR(i,1)+HVACR{I}(i,2);
else disp(['Does not fit for hole ' num2str(I)])
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
%%Hot and cold potable water
figure(figHandle);
subplot(HY+1,HX+2,Hole(I));
XPOT=0+XHR(end,1);
YPOT=0+YHR(end,1);
HPPOT=0+max(max(max(max(HPG),max(HPB)),max(max(HPHS),max(HPHE))),max(HPHR));
for i=1:size(POT{I},1)-1
if POT{I}(i,1)<=X
if POT{I}(i,2)<=Y
if POT{I}(i,1)<=(X-XPOT(i,1))
B=rectangle('Position',[XPOT(i,1) YPOT(i,1) POT{I}(i,1) POT{I}(i,2)],'FaceColor','green');
XPOT(i+1,1)=XPOT(i,1)+POT{I}(i,1);
YPOT(i+1,1)=YPOT(i,1);
HPPOT(end+1,1)=YPOT(i,1)+POT{I}(i,2);
elseif POT{I}(i,2)<=min(YC(:,1))-max(HPPOT)
XPOT(i,1)=0;
YPOT(i,1)=max(HPPOT);
B=rectangle('Position',[XPOT(i,1) YPOT(i,1) POT{I}(i,1) POT{I}(i,2)],'FaceColor','green');
XPOT(i+1,1)=XPOT(i,1)+POT{I}(i,1);
YPOT(i+1,1)=YPOT(i,1);
HPPOT(end+1,1)=YPOT(i,1)+POT{I}(i,2);
else disp(['Does not fit for hole ' num2str(I)])
end
end
else disp(['Does not fit for hole ' num2str(I)])
end
end
%%Determine overlapping of rectangles
l = max(A.Position(1),B.Position(1));
r = min(A.Position(1)+A.Position(3),B.Position(1)+B.Position(3));
b = max(A.Position(2),A.Position(2));
t = min(A.Position(2)+A.Position(4),B.Position(2)+B.Position(4));
r3 = [l b r-l t-b];
if r3(3)>0
if r3(4)>0
disp(['Does not fit for hole ' num2str(I)])
end
end
Your code appears to rely upon sys having been assigned in the base workspace but at the moment I do not see anywhere in the code that you assigned it in the base workspace. You access it from application data at one point but at the moment I do not see it being assigned there
"Your code appears to rely upon sys having been assigned in the base workspace..."
And that is exactly why magically making variables "poof" into existence and jump between workspaces using assignin leads to such buggy (and hard to debug) code. Passing arguments is trivially easy, using nested arrays is simple, and both are much simpler to debug: why not learn some good coding methods today?
@Walter Roberson: errr... there is a question mark, but I am not sure what the question is. I find nested arrays quite convenient for passing data around a GUI internally (between callbacks). Obviously it won't get data into the base workspace, but that it then pretty trivial using output arguments.
I could see nested structures being used for that but I would probably use nested functions with shared variables.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!