push button in gui

2 visualizaciones (últimos 30 días)
Halim
Halim el 30 de Abr. de 2012
im new in matlab gui can someone help me how to run this function in pushbutton gui...
function load_database1();
% We load the database the first time we run the program.
persistent loaded;
persistent w;
if(isempty(loaded))
v=zeros(10304,70);
for i=1:7
cd(strcat('s',num2str(i)));
for j=1:10
a=imread(strcat(num2str(j),'.pgm'));
v(:,(i-1)*10+j)=reshape(a,size(a,1)*size(a,2),1);
end
cd ..
end
w=uint8(v); % Convert to unsigned 8 bit numbers to save memory.
end
loaded=1; % Set 'loaded' to aviod loading the database again.
save w.mat w;
clear

Respuesta aceptada

Image Analyst
Image Analyst el 30 de Abr. de 2012
Try using GUIDE. Place a push button on the GUI, then right click and view the callback. It will make a function in the m-file where you can paste the code you gave.
  3 comentarios
Image Analyst
Image Analyst el 30 de Abr. de 2012
Huh? How will the callback function for your button clash (conflict, interfere) with some other function you have called pushbutton1? Like I said, place a button there on the GUI and call it (set the "tag" property) to something like btnLoadDatabase. Then right click and say Callbacks->View Callback. You will get a function in the m-file called btnLoadDatabase_Click(). In that function paste the code you gave above for your load_database1 function (not including the function line itself of course).
Halim
Halim el 1 de Mayo de 2012
thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by