Data String unreadable in uitable matlab

Hello, Please someone help me
i have problem to display string data from ms.excel to uitable in matlab
this is my code :
[filename,path] = uigetfile('.xlsx')
dataExcel = xlsread(fullfile(path,filename),'sheet1','A2:F50');
name = dataExcel(:,2)
set(handles.uitable1,'data','ColumnName',{'Nama'});
This is the result :
Can you help me, please?

댓글 수: 1

set(handles.uitable1,'data','ColumnName',{'Nama'});
That is invalid. After using the 'data' keyword, you need to pass in the data, such as
set(handles.uitable1, 'data', dataExcel, 'ColumnName', {'Nama'});
Please attach a copy of your xlsx file for testing purposes.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 7월 1일

0 개 추천

Your use of 'Nama' as a header suggets that you expect the column you are selecting to be character vectors -- names. However when you use xlsread with only one output, then what is output is only numeric values and nan, with all character vectors replaced by nan. You would need to use the two or three output form of xlsread() to get at the character vectors.
I recommend that you switch to readtable() instead of xlsread()

댓글 수: 7

sorry I did not make the full code. actually I have more than one column
tableData = [nama,ipk, skor,gjbb,out];
tableData = flipud(sortrows(tableData,5));
set(handles.uitable1,'data',tableData(1:10,:),'ColumnName',{'Nama';'IPK';'Skor_Perilaku';'Gaji_Beban';'Kelayakan'});
as you see the fist column did not display my string data
When you use xlsread() and only look at the first output, then it will never have characters or strings or times in it: only numeric. You have to look at the second or third output of xlsread() to get the strings.
However I recommend that you switch to using readtable() instead of xlsread()
joni nababan
joni nababan 2020년 7월 2일
how to use readtable()?
data = readtable(fullfile(path,filename),'sheet1','A2:F50');
stuff = table2cell(data(1:10,:));
handles.uitable1.Data = stuff;
It's error
% Error using readtable (line 129)
% Invalid parameter name: sheet1.
% % %
% Error in TA>loaddata_Callback (line 87)
% data = readtable(fullfile(path,filename),'sheet1','A2:F50');
data = readtable(fullfile(path,filename), 'sheet', 'sheet1', 'range', 'A2:F50');
stuff = table2cell(data(1:10,:));
handles.uitable1.Data = stuff;
joni nababan
joni nababan 2020년 7월 2일
Thanks, Walter
Can i make plot from that data?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

질문:

2020년 7월 1일

댓글:

2020년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by