Data string unreadable in matlab

1 vue (au cours des 30 derniers jours)
joni nababan
joni nababan le 28 Avr 2020
Commenté : Steven Lord le 29 Avr 2020
Hi, please help
i have a xls file with 6 column. First column is string type and others are numeric. i don't know why i cant read the first column data with 'xlsread'. maybe because it is string. is there any way to read my first column?
here is my code
function loadbutton_Callback(hObject, eventdata, handles)
% hObject handle to loadbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,path] = uigetfile('.xlsx')
dataExcel = xlsread(fullfile(path,filename),'sheet1','A2:F50')
global skor;
global ipk;
global gjbb;
global nama;
cla
axes(handles.axes1)
ipk = dataExcel(:,6)
plot(ipk,'-b.')
grid on
legend('Data Mahasiswa')
ylabel('IPK')
set(gca,'xtick',0:5:size(ipk))
set(gca,'XtickLabel',0:5:size(ipk))
set(gca, 'FontSize', 8)
axes(handles.axes2)
skor = dataExcel(:,5)
plot(skor,'-b.')
grid on
legend('Data Mahasiswa')
ylabel('Skor')
set(gca,'xtick',0:5:size(skor))
set(gca,'XtickLabel',0:5:size(skor))
set(gca, 'FontSize', 8)
axes(handles.axes3)
gjbb = dataExcel(:,4)
plot(gjbb,'-b.')
grid on
legend('Data Mahasiswa')
ylabel('Gaji Beban(Juta)')
set(gca,'xtick',0:5:size(gjbb))
set(gca,'XtickLabel',0:5:size(gjbb))
set(gca, 'FontSize', 8)
nama = dataExcel(:,2)
function processbutton_Callback(hObject, eventdata, handles)
fis=readfis('fuzzy.fis');
global ipk
global skor
global gjbb
global nama
out = evalfis([ipk, skor, gjbb],fis)
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';'Output'});
and here is the result
I dont know why the first column is 'NaN'
what should i do to fix it?
Thankyou

Réponses (1)

Steven Lord
Steven Lord le 28 Avr 2020
The first output argument from xlsread contains the numeric data from the file. Your text data doesn't represent a number so it appears in that output as NaN. If you must use xlsread you want to ask for the second and/or third output as well.
However, as the note at the top of that documentation page states, xlsread is not recommended as of release R2019a for reasons given in the Compatibility Considerations section on that page. Consider reading your data into a table array using readtable instead.
  2 commentaires
joni nababan
joni nababan le 28 Avr 2020
i use matlab R2014b
how can i fix it?
Steven Lord
Steven Lord le 29 Avr 2020
If you must use xlsread you want to ask for the second and/or third output as well.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by