Import data from Excel to Matlab GUI

Hi everyone!
Hope all is well!
I have a slight problem with uploading my excel file that includes TEXT and NUMBER to Matlab GUI (Uitable).
On my excel file i had TWO columns, 1st column in text format and the 2nd column in number format.
As shown below it only displays the second column NOT the first column.
I typed this on the command window on Matlab GUI:
>> data = xlsread('height.xlsx');
>> data
data =
55
83
79
40
58

 採用された回答

Adam Danz
Adam Danz 2020 年 4 月 22 日

0 投票

xlsread returns the numeric data in a matrix. The first column of your data are not numeric.
Use readtable() instead.

6 件のコメント

Miss B
Miss B 2020 年 4 月 22 日
編集済み: Miss B 2020 年 4 月 22 日
Thank you.
I tried that but, now when I try load the data from the workplace, nothing appears on the uitable in GUI.
But when i go back to using xlsread on command window - the data loads successfully from workplace and appears on the table.
Adam Danz
Adam Danz 2020 年 4 月 22 日
That may be due to an error in reading in the data or it could be due to an error in assigning the values to the uitable. Have you checked that the data is read-in correctly? If that's the error, what's the output of readtable() and what inputs are you using? If the problem is with assigning the data to a uitable, that's a different problem than what's asked in the quesiton.
Miss B
Miss B 2020 年 4 月 22 日
This is the output for readtable() on COMMAND WINDOW.
data =
5×2 table
Var1 Var2
__________ ____
{'weight'} 56
{'food'} 47
{'height'} 89
'I have a slight problem with uploading my excel file that includes TEXT and NUMBER to Matlab GUI (Uitable).'
I made it clear here ^ that itll display on a Uitable on Matlab GUI.
Adam Danz
Adam Danz 2020 年 4 月 22 日
You can convert the table to a cell array before loading it to the uitable,
C = table2cell(T)
Miss B
Miss B 2020 年 4 月 22 日
Thank you very much yet again!
Your help and support is immensely appreciated.
Adam Danz
Adam Danz 2020 年 4 月 22 日
Glad I could help!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2020 年 4 月 22 日

編集済み:

2020 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by