How to convert char data to num??
108 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have .mat file which contains labels of my image dataset. These labels are numbers (0,1,2,3,4,5,6) but in mat file these are saved as characters ('0','1','2','3','4','5','6'). How to convert these chars to num??
% Features Extraction of Face based on HOG
clear;
testing=imageSet('Testing\','recursive'); % folder name of the database
K=1;
for i=1:size(testing,2 )
for j=1:testing(i).Count
Face=read(testing(i),j);
Face=imresize(Face, [48 48]);
HOG_Features=extractHOGFeatures(Face);
testingFeatures(K,:)=single(HOG_Features);
testinglabel{K}=testing(i).Description;
K=K+1;
end
persons{i}=testing(i).Description;
end
testinglabel=testinglabel';
csvwrite(' Testing.csv', testingFeatures)
0 Commenti
Risposte (1)
Adam Danz
il 22 Giu 2018
In your example, "characters ('0','1','2','3','4','5','6')" it looks like the labels might be a cell array of strings. For example
c = {'1','2','3','4'};
If that's the case, you can use
d = str2double(c);
Here's the conversion if the labels are a single string of numbers.
% single string of numbers
c = '1 2 3 4 5';
d = str2double(strsplit(c));
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Type Conversion 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!