Ho cambiato un po' il codice. Ora mi dice che non e' definita la variabile fluid che invece penso di aver definito nella Callback relativa al popup-menu fluid.
Di seguito il codice:
function varargout = test2(varargin)
% TEST2 MATLAB code for test2.fig
% TEST2, by itself, creates a new TEST2 or raises the existing
% singleton*.
%
% H = TEST2 returns the handle to a new TEST2 or the handle to
% the existing singleton*.
%
% TEST2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TEST2.M with the given input arguments.
%
% TEST2('Property','Value',...) creates a new TEST2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before test2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to test2_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 test2
% Last Modified by GUIDE v2.5 23-Oct-2017 14:31:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @test2_OpeningFcn, ...
'gui_OutputFcn', @test2_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 test2 is made visible.
function test2_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 test2 (see VARARGIN)
% Choose default command line output for test2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes test2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = test2_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;
% --- Executes on selection change in popupmenu_correlation.
function popupmenu_correlation_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_correlation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_correlation contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_correlation
% Determine the selected data set.
str = source.String;
val = source.Value;
% Set current data to the selected data set.
switch str{val};
case 'Gungor & Winterton.1986' % User selects Gungor & Winterton.1986.
a=1;
set(handles.Validation,'Vertical and horizontal flow in tubes and annuli, Water/R11/R22/R113/R114/Ethylene/Glycol, d=2.95-3.2mm, p=0.08-20.6bar');
case 'Chien et al.2014 ' % User selects Chien et al.2014.
a=2;
set(handles.Validation,'Horizontal macro and mini-channels:d=1.5,3.0,6.61,7.49 mm, R410A, G=100-600 kg/m2s, q=10-40 kW/m2, Tsat=5-15 *C, x=0.2-1');
end
% --- Executes during object creation, after setting all properties.
function popupmenu_correlation_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_correlation (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 selection change in popupmenu_fluid.
function popupmenu_fluid_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_fluid (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_fluid contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_fluid
% Determine the selected data set.
str = source.String;
val = source.Value;
% Set current data to the selected data set.
switch str{val};
case 'R134a' % User selects R134a
fluid='R134a';
case 'R410A' % User selects R410A.
fluid='r410a.mix';
end
% --- Executes during object creation, after setting all properties.
function popupmenu_fluid_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_fluid (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
function Tsat_Callback(hObject, eventdata, handles)
% hObject handle to Tsat (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 Tsat as text
% str2double(get(hObject,'String')) returns contents of Tsat as a double
% --- Executes during object creation, after setting all properties.
function Tsat_CreateFcn(hObject, eventdata, handles)
% hObject handle to Tsat (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 Psat_Callback(hObject, eventdata, handles)
% hObject handle to Psat (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 Psat as text
% str2double(get(hObject,'String')) returns contents of Psat as a double
% --- Executes during object creation, after setting all properties.
function Psat_CreateFcn(hObject, eventdata, handles)
% hObject handle to Psat (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 G_Callback(hObject, eventdata, handles)
% hObject handle to G (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 G as text
% str2double(get(hObject,'String')) returns contents of G as a double
% --- Executes during object creation, after setting all properties.
function G_CreateFcn(hObject, eventdata, handles)
% hObject handle to G (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 q_Callback(hObject, eventdata, handles)
% hObject handle to q (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 q as text
% str2double(get(hObject,'String')) returns contents of q as a double
% --- Executes during object creation, after setting all properties.
function q_CreateFcn(hObject, eventdata, handles)
% hObject handle to q (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 x_Callback(hObject, eventdata, handles)
% hObject handle to x (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 x as text
% str2double(get(hObject,'String')) returns contents of x as a double
% --- Executes during object creation, after setting all properties.
function x_CreateFcn(hObject, eventdata, handles)
% hObject handle to x (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 d_Callback(hObject, eventdata, handles)
% hObject handle to d (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 d as text
% str2double(get(hObject,'String')) returns contents of d as a double
% --- Executes during object creation, after setting all properties.
function d_CreateFcn(hObject, eventdata, handles)
% hObject handle to d (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 c_l_Callback(hObject, eventdata, handles)
% hObject handle to c_l (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 c_l as text
% str2double(get(hObject,'String')) returns contents of c_l as a double
% --- Executes during object creation, after setting all properties.
function c_l_CreateFcn(hObject, eventdata, handles)
% hObject handle to c_l (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 rho_l_Callback(hObject, eventdata, handles)
% hObject handle to rho_l (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 rho_l as text
% str2double(get(hObject,'String')) returns contents of rho_l as a double
% --- Executes during object creation, after setting all properties.
function rho_l_CreateFcn(hObject, eventdata, handles)
% hObject handle to rho_l (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 rho_v_Callback(hObject, eventdata, handles)
% hObject handle to rho_v (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 rho_v as text
% str2double(get(hObject,'String')) returns contents of rho_v as a double
% --- Executes during object creation, after setting all properties.
function rho_v_CreateFcn(hObject, eventdata, handles)
% hObject handle to rho_v (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 edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (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 edit12 as text
% str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (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 edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (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 edit13 as text
% str2double(get(hObject,'String')) returns contents of edit13 as a double
% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit13 (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 h_l_Callback(hObject, eventdata, handles)
% hObject handle to h_l (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 h_l as text
% str2double(get(hObject,'String')) returns contents of h_l as a double
% --- Executes during object creation, after setting all properties.
function h_l_CreateFcn(hObject, eventdata, handles)
% hObject handle to h_l (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 edit15_Callback(hObject, eventdata, handles)
% hObject handle to edit15 (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 edit15 as text
% str2double(get(hObject,'String')) returns contents of edit15 as a double
% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit15 (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 lambda_Callback(hObject, eventdata, handles)
% hObject handle to lambda (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 lambda as text
% str2double(get(hObject,'String')) returns contents of lambda as a double
% --- Executes during object creation, after setting all properties.
function lambda_CreateFcn(hObject, eventdata, handles)
% hObject handle to lambda (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 edit17_Callback(hObject, eventdata, handles)
% hObject handle to edit17 (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 edit17 as text
% str2double(get(hObject,'String')) returns contents of edit17 as a double
% --- Executes during object creation, after setting all properties.
function edit17_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit17 (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 HTC_Callback(hObject, eventdata, handles)
% hObject handle to HTC (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 HTC as text
% str2double(get(hObject,'String')) returns contents of HTC as a double
% --- Executes during object creation, after setting all properties.
function HTC_CreateFcn(hObject, eventdata, handles)
% hObject handle to HTC (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_compute.
function pushbutton_compute_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_compute (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Tsat=str2num(get(handles.Tsat,'string'));
p_sat=refpropm('P','T',Tsat+273.15,'Q',0,fluid);
set(handles.Psat,'string',p_sat)
G=str2num(get(handles.G,'string'));
q=str2num(get(handles.q,'string'))*1000;
x=str2num(get(handles.x,'string'));
d_int=str2num(get(handles.d,'string'))*1000;
M = refpropm('M','T',Tsat+273.15,'Q',0,fluid); %kg/mol
p_crit = refpropm('P','C',0,' ',0,fluid); %kPa
lambda_l = refpropm('L','T',Tsat+273.15,'Q',0,fluid);
sigma = refpropm('I','T',Tsat+273.15,'Q',0,fluid);
c_l = refpropm('C','T',Tsat+273.15,'Q',0,fluid);
rho_l = refpropm('D','T',Tsat+273.15,'Q',0,fluid);
mu_l = refpropm('V','T',Tsat+273.15,'Q',0,fluid);
mu_v = refpropm('V','T',Tsat+273.15,'Q',1,fluid);
h_l=refpropm('H','T',Tsat+273.15,'Q',0,fluid); %J/kg
h_v=refpropm('H','T',Tsat+273.15,'Q',1,fluid); %J/kg
rho_v = refpropm('D','T',Tsat+273.15,'Q',1,fluid);
set(handles.c_l,'string',c_l)
set(handles.lambda,'string',lambda_l)
set(handles.sigma,'string',sigma)
set(handles.rho_l,'string',rho_l)
set(handles.rho_v,'string',rho_v)
set(handles.mu_l,'string',mu_l)
set(handles.mu_v,'string',mu_v)
set(handles.h_l,'string',h_l)
set(handles.h_v,'string',h_v)
set(handles.Current_condition,'string', 'Psat=',handles.Psat,'bar','G=',handles.G,'kg/m^2s','q=',handles.q,'kW/m^2','d=',handles.d,'mm');
x_plot=0:0.05:1;
if a==1
HTC=Gungor_Winterton_1986(x,p_sat,p_crit,G,q,d_int,M,lambda_l,c_l,rho_l,rho_v,mu_l,mu_v,l_evap);
for i=1:length(x_plot)
alpha_plot(i)=Gungor_Winterton_1986(x_plot(i),p_sat,p_crit,G,q,d_int,M,lambda_l,c_l,rho_l,rho_v,mu_l,mu_v,l_evap)
end
elseif a==2
HTC=Chien_et_al_2014(x,p_sat,p_crit,G,q,d_int,M,lambda_l,c_l,rho_l,rho_v,mu_l,sigma);
for i=1:length(x_plot)
alpha_plot(i)=Chien_et_al_2014(x_plot(i),p_sat,p_crit,G,q,d_int,M,lambda_l,c_l,rho_l,rho_v,mu_l,sigma)
end
end
plot (handles.axes2,x_plot,alpha_plot)
e l'errore:
Undefined function or variable 'fluid'.
Error in test2>pushbutton_compute_Callback (line 523)
p_sat=refpropm('P','T',Tsat+273.15,'Q',0,fluid);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in test2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)test2('pushbutton_compute_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback