How to change table to 2x1 double for app designer?

1 回表示 (過去 30 日間)
Thi Ng
Thi Ng 2020 年 4 月 21 日
回答済み: Thi Ng 2020 年 4 月 27 日
Hi Everyone,
I am trying to translate my script from the editor to app designer. I am lacking to understand how my data input for MATLAB editor is different from the input for the app designer.
  1. case input is a variable with a value of 2x1 double (my script works with this)
  2. case input would be an excel file uploaded by the user (causes error: Unrecognised function or variable)
The code to upload the excel file is:
[file, path] = uigetfile('*.xlsx');
data = readtable(fullfile(path, file));
app.UITable.Data = data;
data2 = app.UITable.Data
The second case would be a table. The difference in the input files causes an error. I don’t want to change the rest of the script as it is coded for a scatterplot with specified colormaps, it would be a pain to change it again. I am just looking for a way to transform the table into a suitable format.
I am very new to MATLAB and would appreciate any kind of help.
Thanks,
Update: table2array gives me the following error:
  2 件のコメント
Jyotsna Talluri
Jyotsna Talluri 2020 年 4 月 24 日
Can you paste the whole error message you are getting
Thi Ng
Thi Ng 2020 年 4 月 27 日
Hi Jyotsna Talluri,
I have solved this issue by making 'data' a property and by adding:
app.UITable.Data = app.data;
Thank you for your message. The whole error can be seen in the screenshot, when sliding the window to the right.
It says:
Error using table2array (line 37)
Unable to concatenate the table variables 'Var1' and 'Var2', because their types are cell and double.
Best,
Thi

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

採用された回答

Thi Ng
Thi Ng 2020 年 4 月 27 日
Hi Jyotsna Talluri,
I have solved this issue by making 'data' a property and by adding:
app.UITable.Data = app.data;
Thank you for your message. The whole error can be seen in the screenshot, when sliding the window to the right.
It says:
Error using table2array (line 37)
Unable to concatenate the table variables 'Var1' and 'Var2', because their types are cell and double.
Best,
Thi

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by