image thumbnail

Cálculo de Propiedades Térmicas de Alimentos - Choi Okos

by

 

Se utilizan las ecuaciones de Choi y Okos en un GUI de MATLAB para calcular las propiedades térmicas

ChoiOkos_GUI_Graficas.m
function varargout = ChoiOkos_GUI_Graficas(varargin)
% CHOIOKOS_GUI_GRAFICAS MATLAB code for ChoiOkos_GUI_Graficas.fig
%      CHOIOKOS_GUI_GRAFICAS, by itself, creates a new CHOIOKOS_GUI_GRAFICAS or raises the existing
%      singleton*.
%
%      H = CHOIOKOS_GUI_GRAFICAS returns the handle to a new CHOIOKOS_GUI_GRAFICAS or the handle to
%      the existing singleton*.
%
%      CHOIOKOS_GUI_GRAFICAS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CHOIOKOS_GUI_GRAFICAS.M with the given input arguments.
%
%      CHOIOKOS_GUI_GRAFICAS('Property','Value',...) creates a new CHOIOKOS_GUI_GRAFICAS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ChoiOkos_GUI_Graficas_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ChoiOkos_GUI_Graficas_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 ChoiOkos_GUI_Graficas

% Last Modified by GUIDE v2.5 31-Dec-2011 00:45:03

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ChoiOkos_GUI_Graficas_OpeningFcn, ...
                   'gui_OutputFcn',  @ChoiOkos_GUI_Graficas_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 ChoiOkos_GUI_Graficas is made visible.
function ChoiOkos_GUI_Graficas_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 ChoiOkos_GUI_Graficas (see VARARGIN)

% Choose default command line output for ChoiOkos_GUI_Graficas
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes ChoiOkos_GUI_Graficas wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = ChoiOkos_GUI_Graficas_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 cuadro_proteina_Callback(hObject, eventdata, handles)
% hObject    handle to cuadro_proteina (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cuadro_proteina as text
%        str2double(get(hObject,'String')) returns contents of cuadro_proteina as a double


% --- Executes during object creation, after setting all properties.
function cuadro_proteina_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cuadro_proteina (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 cuadro_grasa_Callback(hObject, eventdata, handles)
% hObject    handle to cuadro_grasa (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cuadro_grasa as text
%        str2double(get(hObject,'String')) returns contents of cuadro_grasa as a double


% --- Executes during object creation, after setting all properties.
function cuadro_grasa_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cuadro_grasa (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 cuadro_carbohidratos_Callback(hObject, eventdata, handles)
% hObject    handle to cuadro_carbohidratos (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cuadro_carbohidratos as text
%        str2double(get(hObject,'String')) returns contents of cuadro_carbohidratos as a double


% --- Executes during object creation, after setting all properties.
function cuadro_carbohidratos_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cuadro_carbohidratos (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 cuadro_fibra_Callback(hObject, eventdata, handles)
% hObject    handle to cuadro_fibra (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cuadro_fibra as text
%        str2double(get(hObject,'String')) returns contents of cuadro_fibra as a double


% --- Executes during object creation, after setting all properties.
function cuadro_fibra_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cuadro_fibra (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 cuadro_ceniza_Callback(hObject, eventdata, handles)
% hObject    handle to cuadro_ceniza (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cuadro_ceniza as text
%        str2double(get(hObject,'String')) returns contents of cuadro_ceniza as a double


% --- Executes during object creation, after setting all properties.
function cuadro_ceniza_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cuadro_ceniza (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 cuadro_agua_Callback(hObject, eventdata, handles)
% hObject    handle to cuadro_agua (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of cuadro_agua as text
%        str2double(get(hObject,'String')) returns contents of cuadro_agua as a double


% --- Executes during object creation, after setting all properties.
function cuadro_agua_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cuadro_agua (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 T0_Callback(hObject, eventdata, handles)
% hObject    handle to T0 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of T0 as text
%        str2double(get(hObject,'String')) returns contents of T0 as a double


% --- Executes during object creation, after setting all properties.
function T0_CreateFcn(hObject, eventdata, handles)
% hObject    handle to T0 (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 dT_Callback(hObject, eventdata, handles)
% hObject    handle to dT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of dT as text
%        str2double(get(hObject,'String')) returns contents of dT as a double


% --- Executes during object creation, after setting all properties.
function dT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to dT (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 Tf_Callback(hObject, eventdata, handles)
% hObject    handle to Tf (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Tf as text
%        str2double(get(hObject,'String')) returns contents of Tf as a double


% --- Executes during object creation, after setting all properties.
function Tf_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Tf (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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
proteina = str2double(get(handles.cuadro_proteina,'String'));
grasa = str2double(get(handles.cuadro_grasa,'String'));
carbohidratos = str2double(get(handles.cuadro_carbohidratos,'String'));
fibra = str2double(get(handles.cuadro_fibra,'String'));
ceniza = str2double(get(handles.cuadro_ceniza,'String'));
agua = str2double(get(handles.cuadro_agua,'String'));
T_inicial = str2double(get(handles.T0,'String'));
delta_T = str2double(get(handles.dT,'String'));
T_final = str2double(get(handles.Tf,'String'));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if proteina<0 || isnan(proteina) || proteina > 100
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
if grasa<0 || isnan(grasa) || grasa > 100
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
if carbohidratos<0 || isnan(carbohidratos) || carbohidratos > 100
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
if fibra<0 || isnan(fibra) || fibra > 100
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
if ceniza<0 || isnan(ceniza) || ceniza > 100
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
if agua<0 || isnan(agua) || agua > 100
    errordlg('Valor Fuera de Rango','ERROR')
    return
end

if isnan(T_inicial )
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
if delta_T <= 0 || isnan(delta_T)
    errordlg('Verifica el valor de Delta T','ERROR')
    return
end
if isnan(T_final)
    errordlg('Valor Fuera de Rango','ERROR')
    return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Test_100 = agua + ceniza + fibra + carbohidratos + grasa + proteina;
if Test_100 ~= 100 || isnan(Test_100)
    errordlg('Verificar la Composicin del Alimento', 'ERROR')
    return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[T,rho,k,Cp,alpha]=ProgramaChoiOkos_GUI_Graficas(proteina,grasa,carbohidratos,...
    fibra,ceniza,agua,T_inicial,delta_T,T_final);
axes(handles.graficas1)
% Create plot
plot(T,rho,'LineWidth',2,'Color',[1 0 0]);
% Create xlabel
xlabel('Temperatura [C]','FontWeight','bold');
% Create ylabel
ylabel('\rho [kg/m^3]','FontWeight','bold');
plot_T_rho_save(T,rho)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(handles.axes2)
plot(T,k,'LineWidth',2,'Color',[1 0 0]);
% Create xlabel
xlabel('Temperatura [C]','FontWeight','bold');
% Create ylabel
ylabel('k [W/m.K]','FontWeight','bold');
plot_T_k_save(T,k)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(handles.axes3)
% Create plot
plot(T,Cp,'LineWidth',2,'Color',[1 0 0]);
% Create xlabel
xlabel('Temperatura [C]','FontWeight','bold');
% Create ylabel
ylabel('C_p [kJ/kg.K]','FontWeight','bold');
plot_T_Cp_save(T,Cp)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(handles.axes4)
% Create plot
plot(T,alpha,'LineWidth',2,'Color',[1 0 0]);
% Create xlabel
xlabel('Temperatura [C]','FontWeight','bold');
% Create ylabel
ylabel('\alpha [m^2/s]','FontWeight','bold');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot_T_alpha_save(T,alpha)
%==========================================================================


% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
opc = questdlg('Desea salir del programa?','SALIR','Si','No','No');
if strcmp(opc,'No')
    return;
end
% Hint: delete(hObject) closes the figure
delete(hObject);


% --- Executes on key press with focus on pushbutton1 and none of its controls.
function pushbutton1_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in boton_salida.
function boton_salida_Callback(hObject, eventdata, handles)
% hObject    handle to boton_salida (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
opc = questdlg('Desea salir del programa?','SALIR','Si','No','No');
if strcmp(opc,'No')
    return;
end
close all

Contact us