Matlab GUI callback function problem.

3 Ansichten (letzte 30 Tage)
Kartavya
Kartavya am 20 Apr. 2014
Hi I'm using guide and I have created the GUI interface. I have 3 buttons and various user imput locations.
Each button uses certain amount of inputs and creates a graph using various functions and equations.
I want to create two more buttons, one that replaces the plot to show another plot and one button to return to the previous plot.
Any idea how I can go about doing that?
First button
function EXECUTE4_Callback(hObject, eventdata, handles)
% hObject handle to EXECUTE4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
N = str2num(get(handles.N,'String'));
FourDigit = str2num(get(handles.FourDigit,'String'));
alpha = str2num(get(handles.alpha4,'String'));
[x,y]= Airfoil4 (N,N,FourDigit);
[xmid,ymid,Cp]=HessSmithPanel (x,y,alpha);
[xU,yU,CpU]=UpperSurface (xmid,ymid,Cp,N);
[iU_FS,xU_FS] = FalknerSkan(xU,CpU);
[iU_SL,xU_SL] = StratfordLBL(xU,CpU);
[iU_ST,xU_ST] = StratfordTBL(xU,CpU);
xFS=xU_FS;
xSL=xU_SL;
xST=xU_ST;
yFS=yU(iU_FS);
ySL=yU(iU_SL);
yST=yU(iU_ST);
axes (handles.axes1);
plot(x,y,'b',xSL,ySL,'*r',xST,yST,'*k',xFS,yFS,'*g');
axis([-.1 1.1 -.4 .4]);
legend ('Airfoil Contour', 'Stratford LBL', 'Stratford TBL','Falkner-Skan');
title('Flow Separation Point (FSP)');
xlabel('x/c');
ylabel('y/c');
guidata (hObject, handles);
Second Button
function EXECUTEC_Callback(hObject, eventdata, handles)
% hObject handle to EXECUTEC (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
N = str2num(get(handles.N,'String'));
alpha = str2num(get(handles.alphaC,'String'));
[x,y,N]= AirfoilC ;
[xmid,ymid,Cp]=HessSmithPanel (x,y,alpha);
[xU,yU,CpU]=UpperSurface (xmid,ymid,Cp,N);
[iU_FS,xU_FS] = FalknerSkan(xU,CpU);
[iU_SL,xU_SL] = StratfordLBL(xU,CpU);
[iU_ST,xU_ST] = StratfordTBL(xU,CpU);
xFS=xU_FS;
xSL=xU_SL;
xST=xU_ST;
yFS=yU(iU_FS);
ySL=yU(iU_SL);
yST=yU(iU_ST);
axes (handles.axes1);
plot(x,y,'b',xSL,ySL,'*r',xST,yST,'*k',xFS,yFS,'*g');
axis([-.1 1.1 -.4 .4]);
legend ('Airfoil Contour', 'Stratford LBL', 'Stratford TBL','Falkner-Skan');
title('Flow Separation Point (FSP)');
xlabel('x/c');
ylabel('y/c');
guidata (hObject, handles);
Third Button
function EXECUTE5_Callback(hObject, eventdata, handles)
% hObject handle to EXECUTE5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
N = str2num(get(handles.N,'String'));
FiveDigit = str2num(get(handles.FiveDigit,'String'));
alpha = str2num(get(handles.alpha5,'String'));
[x,y]= Airfoil5 (N,N,FiveDigit);
[xmid,ymid,Cp]=HessSmithPanel (x,y,alpha);
[xU,yU,CpU]=UpperSurface (xmid,ymid,Cp,N);
[iU_FS,xU_FS] = FalknerSkan(xU,CpU);
[iU_SL,xU_SL] = StratfordLBL(xU,CpU);
[iU_ST,xU_ST] = StratfordTBL(xU,CpU);
xFS=xU_FS;
xSL=xU_SL;
xST=xU_ST;
yFS=yU(iU_FS);
ySL=yU(iU_SL);
yST=yU(iU_ST);
axes (handles.axes1);
plot(x,y,'b',xSL,ySL,'*r',xST,yST,'*k',xFS,yFS,'*g');
axis([-.1 1.1 -.4 .4]);
legend ('Airfoil Contour', 'Stratford LBL', 'Stratford TBL','Falkner-Skan');
title('Flow Separation Point (FSP)');
xlabel('x/c');
ylabel('y/c');
guidata (hObject, handles);
Figure One
function FigureG_Callback(hObject, eventdata, handles)
% hObject handle to FigureG (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes (handles.axes1);
plot(x,y,'b',xSL,ySL,'*r',xST,yST,'*k',xFS,yFS,'*g');
axis([-.1 1.1 -.4 .4]);
legend ('Airfoil Contour', 'Stratford LBL', 'Stratford TBL','Falkner-Skan');
title('Flow Separation Point (FSP)');
xlabel('x/c');
ylabel('y/c');
guidata (hObject, handles);
Figure Two
% --- Executes on button press in FigureP.
function FigureP_Callback(hObject, eventdata, handles)
% hObject handle to FigureP (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes (handles.axes1);
plot(xU,CpU);
set(gca, 'YDir', 'reverse');
axis auto
title('Pressure Distribution');
xlabel('x/c');
ylabel('Cp');
guidata (hObject, handles);
TL;DR: Basically when I press the last two buttons, the function isn't recieving information that is created by the previous functions. Usually one of the button 1/2/3 is pressed. And then the user should press the figure buttons. Please let me know if there is an easier way to do this.
thank you

Antworten (0)

Kategorien

Mehr zu Airfoil tools finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by