How to take input from Edit Text Field and load the data with Push Button

26 ビュー (過去 30 日間)
amonako yim
amonako yim 2021 年 3 月 6 日
編集済み: Cris LaPierre 2021 年 3 月 6 日
hello,
I want to create a guide interface where the user enters the file name .xlsx or .csv in a text field and load the data from the table by clicking on a button.
Thanks

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 3 月 6 日
編集済み: Cris LaPierre 2021 年 3 月 6 日
I'd be wary of having manual name entry. See this answer on how to use uigetfile.
If you are new to app designer, I suggest going through the tutorial. Once you are familiar with accessing properties of your components and using callbacks, the approach for your original question is
  1. add a callback to the button
  2. In the callback, retrieve the Value property of the edit field
  3. Use the retrieved value to indicate the file in your loading function.
It could look something like this
% Button pushed function: LoadButton
function LoadButtonPushed(app, event)
fname = app.EditField.Value;
app.data = readmatrix(fname);
end
See this page for how to share data within an app (here, the variable app.data).

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by