Matlab Calling 'Import Data' with GUI Button

不打扰是莪最后的温柔 提交于 2019-12-10 10:20:21

问题


I'm working in a GUI in Matlab R2014b that uses some data from a txt file, so i want to call the 'Import Data' window to permit the user select the data from a file when pushing a button. Is there a way to do this?


回答1:


The function uiimport is used for importing data interactively. This seems to be what gets called by Matlab's toolbar's "import data" button.

Excerpting from the documenatation,

uiimport opens a dialog to interactively load data from a file or the clipboard. MATLAB® displays a preview of the data in the file.

uiimport('-file') presents the file selection dialog first.

S = uiimport(___) stores the resulting variables as fields in the struct S.

So, just set

uiimport('-file');

as the button's callback.



来源:https://stackoverflow.com/questions/29331836/matlab-calling-import-data-with-gui-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!