Why my Gui does'nt do the Graphic?

% --- Executes on selection change in plot_popup.
function plot_popup_Callback(hObject, eventdata, handles)
% hObject handle to plot_popup (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 plot_popup contents as cell array
% contents{get(hObject,'Value')} returns selected item from plot_popup
% Agora, dependendo do tipo de meio de têmpera escolhido, a resposta da
% temperatura será diferente, portanto:
global H Tm
switch cellstr(get(hObject,'String'))
case 'Ar à 27 ºC'
H = 200;
Tm = 300;
case 'Sopro de Ar à 27 ºC'
H = 250;
Tm = 300;
case 'Óleo convencional à 65 ºC'
H = 3000;
Tm = 338;
case 'Água à 32 ºC'
H = 5000;
Tm = 305;
case 'Água agitada à 32 ºC'
H = 12000;
Tm = 305;
end
% --- Executes during object creation, after setting all properties.
function plot_popup_CreateFcn(hObject, eventdata, handles)
% hObject handle to plot_popup (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','black');
end
% --- Executes on button press in Botao_Simular.
function Botao_Simular_Callback(hObject, eventdata, handles)
% hObject handle to Botao_Simular (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global t H Tm
dt = 0.5;
% inputs
d = str2double(get(handles.Densidade,'String'));
k = str2double(get(handles.Condutividade,'String'));
Cp = str2double(get(handles.Capacidade,'String'));
T = str2double(get(handles.edit2,'String'));
r = str2double(get(handles.Raio,'String'));
% Agora, dependendo do tipo de meio de têmpera escolhido, a resposta da
% temperatura será diferente, portanto:
% Cálculo==============================================================
Bi = H*r/k;
a = k/Cp/d;
% Como Fo = at/r^2, temos:
t = [0:1:r.^2*log(0.1)/-Bi/a];
% =============================
% De acordo com a equação 5.13:
Tp = exp(-Bi.*a.*t./r.^2);
% Em função da Temperatura temos:
Tp = Tm + (exp.(-Bi.*a.*t./r^2)).*(T - Tm);
plot(t,Tp);
%-----------------------------------------------------------------------

Answers (1)

Jesuel - put a breakpoint at the first line of your Botao_Simular_Callback and launch your GUI. Do all the necessary selections and then press the Botao Simular button and observe that the debugger pauses at the line where you put the breakpoint. Step through the lines of code and see what happens. When I try to evaluate this function (with dummy inputs), I observe the following error
Argument to dynamic structure reference must evaluate to a valid field name.
This occurs at the line
Tp = Tm + (exp.(-Bi.*a.*t./r^2)).*(T - Tm);
because of the period just after the exp function call. MATLAB assumes that exp is a structure with your code trying to access the field
(-Bi.*a.*t./r^2)
Just remove the period, replacing your line with
Tp = Tm + (exp(-Bi.*a.*t./r^2)).*(T - Tm);

This question is closed.

Tags

Asked:

on 7 Dec 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!