Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How do I work with the gui?

2 visualizaciones (últimos 30 días)
new user 00
new user 00 el 1 de Jul. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have to prepare a gui where i should call an excel file using a browsing push button and use its data for further calculation. This file will basically have two rows, but I'm not aware of the number of elements in the table.So I was thinking if I can retrieve the data and store it in two arrays. But I'm totally new to gui and don't know how to do it. So, can someone help? Thanks in advance!!

Respuestas (2)

Sri Harish G
Sri Harish G el 2 de Jul. de 2018
You can use the uibutton function to create a push button. You can then edit the ButtonPushedFcn Property of the push button to call a function that will look through the files and open the selected excel file as a table.
b=uibutton('Text','Browse','ButtonPushedFcn','browse_click()');
You can then define the browse_click function as:
function browse_click()
[selectedFile,pathName]=uigetfile({'*.xlsx;*.xlsm;*.xls;*.xltm;*.xltx','Excel Files (*.xlsx,*.xlsm,*.xls,*.xltm,*.xltx)'});
cd(pathName(1:end-1));
tab=readtable(selectedFile);
assignin('base','tab',tab);
end
This will save the selected Excel File as a table in variable tab in the base workspace.
  1 comentario
Jan
Jan el 2 de Jul. de 2018
Changing the current folder is a source of bugs. Prefer using absolute path names:
tab = readtable(fullfile(pathname, selectedFile));
Instead of creating variables in the base workspace, it is more secure to store them in the current figure, e.g. in the UserData or ApplicationData of any UI element.

Jan
Jan el 2 de Jul. de 2018
You can create a GUI by GUIDE, AppDesigner or programmatically. For the latter you find the excellent 41 GUI examples. For the other two tools, you find an exhaustive documentation, see https://www.mathworks.com/discovery/matlab-gui.html

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by