How can i save multiple sets on data from MATLAB App Designer to excel?

26 ビュー (過去 30 日間)
Grace Frost
Grace Frost 2020 年 5 月 10 日
回答済み: saleh said bouhliga 2020 年 10 月 10 日
So i have created a call back function for my 'save data' edit text box. So when the user presses the 'save data' button the data from the simulation is saved to an excel file and this is my code below. However if i run multiple simulations and press 'save data' the data is saved on top of the original values and so it only saves one set of data each time.
I wanted to know how to save multiple data sets one after another, underneath one another, every time the user presses 'save data'.
Thanks in advance, Grace

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 10 日
編集済み: Ameer Hamza 2020 年 5 月 10 日
See the 'Range' option of writetable(): https://www.mathworks.com/help/releases/R2020a/matlab/ref/writetable.html#d120e1378251. You can create a property in the app to store the current row. Increment it after each callback and use it to specify the row in excel file.
For example, if the row number is 5, then you can use something like this
writetable(t, 'filename', 'Range', ['A', num2str(5)])
  12 件のコメント
Grace Frost
Grace Frost 2020 年 5 月 10 日
Hi Ameer, sorry to bother again,
but when i save my data it does save but its saves on row 20 or 21 or 22 or 23 for some reason and not at the top of the excel spreadsheet. This is the code i have, dont think it chnaged any of it. Do you know why?
Ameer Hamza
Ameer Hamza 2020 年 5 月 10 日
You have written
.... 'range', ['A2' num2str(.....
replace 'A2' with just 'A'.

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

その他の回答 (1 件)

saleh said bouhliga
saleh said bouhliga 2020 年 10 月 10 日
For example
filename = book1
sheet = sheet1
table name = app.t
writetable(app.t,"Book1.xlsx","Sheet",1);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by