I've been trying to run my matlab GUI but in the command window appears this error: ''error in untitled (line 42) gui_mainfcn(gui_state varargin )''. The entire code is given below. Any soulution?

1 view (last 30 days)
function varargout = calculo_tubos_fp(varargin)
% CALCULO_TUBOS_FP MATLAB code for calculo_tubos_fp.fig
% CALCULO_TUBOS_FP, by itself, creates a new CALCULO_TUBOS_FP or raises the existing
% singleton*.
%
% H = CALCULO_TUBOS_FP returns the handle to a new CALCULO_TUBOS_FP or the handle to
% the existing singleton*.
%
% CALCULO_TUBOS_FP('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CALCULO_TUBOS_FP.M with the given input arguments.
%
% CALCULO_TUBOS_FP('Property','Value',...) creates a new CALCULO_TUBOS_FP or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before calculo_tubos_fp_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to calculo_tubos_fp_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 calculo_tubos_fp
% Last Modified by GUIDE v2.5 28-Dec-2018 12:46:29
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @calculo_tubos_fp_OpeningFcn, ...
'gui_OutputFcn', @calculo_tubos_fp_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 calculo_tubos_fp is made visible.
function calculo_tubos_fp_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 calculo_tubos_fp (see VARARGIN)
% Choose default command line output for calculo_tubos_fp
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes calculo_tubos_fp wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = calculo_tubos_fp_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 boton_calculos_tubos_Callback(hObject, eventdata, handles)
a = get(handles.popupmenu1,'String');
s = get(handles.popupmenu1, 'Value');
n = a(s);
l = get(handles.temperatura,'String');
k = get(handles.presion,'String');
g = get(handles.Ea,'String');
m = get(handles.Ko,'String');
p = get(handles.Xo,'String');
y = get(handles.Xf,'String');
q = get(handles.Fexpansion,'String');
o = get(handles.caudal,'String');
u = get(handles.diametro,'String');
v = get(handles.longitud,'String');
% Declaración de variables y convertimos los datos(letras)a numeros
n1=str2double(n);
T=str2double(l);
P=str2double(k);
Ea=str2double(g);
Ko=str2double(m);
Xo=str2double(p);
Xf=str2double(y);
Fe=str2double(q);
Vo=str2double(o);
D=str2double(u);
L=str2double(v);
R=8.314472;
% Resolución ecuaciones
k=Ko*exp(-Ea/(R*T));
CAo=P/(R*T);
ra=@(XA) 1./((k.*(CAo.^n1).*((1-XA).^n1))./(1+Fe.*XA).^nl);
f=integral(ra,Xo,Xf);
result = ((CAo.*Vo)./((pi./4).*D^.2.*L)).*f;
set(handles.resultado,'String',result);
function boton_atras_tubos_fp_Callback(hObject, eventdata, handles)
close(gcf)
reactor_fp;
function edit1_Callback(hObject, eventdata, handles)
function resultado_CreateFcn(hObject, eventdata, handles)
% 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 popupmenu1_Callback(hObject, eventdata, handles)
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% 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
function temperatura_Callback(hObject, eventdata, handles)
function temperatura_CreateFcn(hObject, eventdata, handles)
% 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 presion_Callback(hObject, eventdata, handles)
function presion_CreateFcn(hObject, eventdata, handles)
% 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 Ea_Callback(hObject, eventdata, handles)
function Ea_CreateFcn(hObject, eventdata, handles)
% 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 Ko_Callback(hObject, eventdata, handles)
function Ko_CreateFcn(hObject, eventdata, handles)
% 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 Xo_Callback(hObject, eventdata, handles)
function Xo_CreateFcn(hObject, eventdata, handles)
% 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 Xf_Callback(hObject, eventdata, handles)
function Xf_CreateFcn(hObject, eventdata, handles)
% 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 Fexpansion_Callback(hObject, eventdata, handles)
function Fexpansion_CreateFcn(hObject, eventdata, handles)
% 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 caudal_Callback(hObject, eventdata, handles)
function caudal_CreateFcn(hObject, eventdata, handles)
% 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 diametro_Callback(hObject, eventdata, handles)
function diametro_CreateFcn(hObject, eventdata, handles)
% 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 longitud_Callback(hObject, eventdata, handles)
function longitud_CreateFcn(hObject, eventdata, handles)
% 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
  4 Comments
Image Analyst
Image Analyst on 28 Dec 2018
How are you running it? By clicking the green run triangle, right? Not by double clicking the .fig file in the current folder panel, right?
Attach both your .m and .fig file with the paper clip icon so we can run it ourselves.

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 29 Dec 2018
Álvaro - in the future, please copy and paste the full error message to this question AND the steps that lead to this error message. I can launch your GUI without error so you will need to describe what you are doing when the error occurs. However, if I press the Calculos button, I observe the following error
Undefined function or variable 'nl'.
Error in
calculo_tubos_fp>boton_calculos_tubos_Callback/@(XA)1./((k.*(CAo.^n1).*((1-XA).^n1))./(1+Fe.*XA).^nl)
Error in integralCalc/midpArea (line 395)
fx = f(x);
Error in integralCalc (line 105)
q = midpArea(FUN,A,B);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in calculo_tubos_fp>boton_calculos_tubos_Callback (line 109)
f=integral(ra,Xo,Xf);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in calculo_tubos_fp (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)calculo_tubos_fp('boton_calculos_tubos_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
The nl is from the line of code
ra=@(XA) 1./((k.*(CAo.^n1).*((1-XA).^n1))./(1+Fe.*XA).^nl);
but nowhere have you defined what nl should be...but you have defined an n and an l so perhaps you mean n*l or something similar. Or should this be n1?

Categories

Find more on Event Functions in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!