Naming output excel-file via edit field in Appdesigner

1 回表示 (過去 30 日間)
Lennart Heid
Lennart Heid 2021 年 6 月 24 日
編集済み: Adam Danz 2021 年 6 月 27 日
Hello,
I am writing a code for a Matlab App for the data acquisition of several sensors. The data will be put into an array which will be saved as an excel-file when using a 'Stop'- pushbutton function. Currently, I am simply using the writetable function and change the name of the table within the code after every session:
writetable(app.T, 'filename.xlsx');
Since I have an interface, I would like to change the filename of the output excel table via a text edit field in the UI figure before starting a session. I know i can access the string of the edit field via the command 'app.DateinameEditField.Value', but how can I connect it to the writetable function?

採用された回答

Adam Danz
Adam Danz 2021 年 6 月 24 日
編集済み: Adam Danz 2021 年 6 月 24 日
> I know i can access the string of the edit field via the command 'app.DateinameEditField.Value', but how can I connect it to the writetable function
filename = [app.DateinameEditField.Value, '.xlsx'];
writetable(app.T, filename)
You may want to include a section of code that validates the user's input to ensure it's a valid file name.
You may also want to include a section of code that checks whether the file exists or not because writetable will over-write files with the same file name and extension (or maybe you want to overwrite it). Another alternative is to append a string of random character like you often see in files within the temp directory.
  • If filename is the name of an existing text file, then the writing function overwrites the file.
  • If filename is the name of an existing spreadsheet file, then the writing function writes the data to the specified location, but does not overwrite any values outside the range of the input data.
  2 件のコメント
Lennart Heid
Lennart Heid 2021 年 6 月 25 日
Thank you very much!!
Adam Danz
Adam Danz 2021 年 6 月 25 日
編集済み: Adam Danz 2021 年 6 月 27 日
Glad I could help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by