Error using table2array -- Input argument must be a table.

17 visualizzazioni (ultimi 30 giorni)
When I run the below code, I get the error "Error using table2array (line 34)
Input argument must be a table."
app.store = table2array(app.UITable.Data);
  2 Commenti
Bruno Luong
Bruno Luong il 21 Ott 2020
Type
dbstop if error
in command line. Run your app, when the error occurs, type
class(app.UITable.Data)
and see what returns

Accedi per commentare.

Risposte (1)

Adam Danz
Adam Danz il 21 Ott 2020
Modificato: Adam Danz il 23 Ott 2020
I don't see a question.
Apparently app.UITable.Data isn't a table. This can happen when the data are from the same class. In that case, you don't need table2array(). For example,
uif = uifigure();
uit = uitable(uif,'Data',magic(9)); % all numeric
>> uit.Data
ans =
47 58 69 80 1 12 23 34 45
57 68 79 9 11 22 33 44 46
67 78 8 10 21 32 43 54 56
77 7 18 20 31 42 53 55 66
6 17 19 30 41 52 63 65 76
16 27 29 40 51 62 64 75 5
26 28 39 50 61 72 74 4 15
36 38 49 60 71 73 3 14 25
37 48 59 70 81 2 13 24 35
uit2 = uitable(uif,'Data',string(magic(9))); % all strings
>> uit2.Data
ans =
9×9 string array
"47" "58" "69" "80" "1" "12" "23" "34" "45"
"57" "68" "79" "9" "11" "22" "33" "44" "46"
"67" "78" "8" "10" "21" "32" "43" "54" "56"
"77" "7" "18" "20" "31" "42" "53" "55" "66"
"6" "17" "19" "30" "41" "52" "63" "65" "76"
"16" "27" "29" "40" "51" "62" "64" "75" "5"
"26" "28" "39" "50" "61" "72" "74" "4" "15"
"36" "38" "49" "60" "71" "73" "3" "14" "25"
"37" "48" "59" "70" "81" "2" "13" "24" "35"

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by