Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How do I work with the gui?
1 回表示 (過去 30 日間)
古いコメントを表示
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!!
0 件のコメント
回答 (2 件)
Sri Harish G
2018 年 7 月 2 日
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 件のコメント
Jan
2018 年 7 月 2 日
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
2018 年 7 月 2 日
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
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!