Azzera filtri
Azzera filtri

how to transfer code in gui?

2 visualizzazioni (ultimi 30 giorni)
cemsi888
cemsi888 il 9 Feb 2015
Commentato: Adam il 10 Feb 2015
hi i wrote a gui program to first read files than make calculations and plot diagrams etc... In Addition on my gui window i created open button to get file from different pfad.
% The OPEN button
btnNumber=6;
labelStr='OPEN';
callbackStr='turbcomp2(''a=6'')';
%Generic Button Information
btnPos=[left/8 yPos-btnHt*10-0.152-btnHt btnWid btnHt];
uicontrol( 'Style','pushbutton',...
'Units','normalized',...
'Position',btnPos,...
'String','OPEN',...
'Callback',callbackStr);
as a callback function i wrote Programm too it Looks subsequent:
[filename,pathname,filterindex]=uigetfile({'*.*','Allfiles(*.*)'},...
'Pick a file',...
'Multiselect','on');
but i dont know how can i Combine These two codes and how can i write second code which is callback as a function? i am new with gui and i could not find any solution. eventhough i did not understand[hObject, eventdata, handles] i searched in Internet however i could not find sufficient Information. Thnaks
  4 Commenti
cemsi888
cemsi888 il 10 Feb 2015
I changed something but i got error massage.
'Function definitions are not permitted in this context.'
btnNumber=6;
labelStr='OPEN';
%Generic Button Information
btnPos=[left/8 yPos-btnHt*10-0.152-btnHt btnWid btnHt];
uicontrol( 'Style','pushbutton',...
'Units','normalized',...
'Position',btnPos,...
'String','OPEN',...
'Callback',@callbackStr6fn);
function callbackStr6fn(uicontrol,eventdata)
[filename,pathname,filterindex]=uigetfile({'*.*','Allfiles(*.*)'},...
'Pick a file',...
'Multiselect','on')
end
Adam
Adam il 10 Feb 2015
If you are working in a script you cannot use functions.
GUIDE is the easiest way to create a simple GUI rather than manually creating the UI components. It will also create callbacks for you so you don't need to worry about getting the syntax right.
If you want to create the components yourself then just change your code from a script to a function by adding:
function myFunctionName
at the top of the file and
end
at the end of your main function. Then you can define further sub-function as you appear to be doing there for callbacks.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by