How to convert a matrix of cell to type double.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hello_world
am 2 Jul. 2016
Kommentiert: James Tursa
am 5 Jul. 2016
Hello Friends,
I have a cell matrix X of size NxD as follows:
X = [5.1000] [3.5000] [1.4000] [0.2000] 'sunday'
[4.9000] [ 3] [1.4000] [0.2000] 'sunday'
[4.7000] [3.2000] [1.3000] [0.2000] 'monday'
[4.6000] [3.1000] [1.5000] [0.2000] 'tuesday'
[ 5] [3.6000] [1.4000] [0.2000] 'tuesday'
[5.4000] [3.9000] [1.7000] [0.4000] 'sunday'
I want to convert it to type double. The last labeled column could be either type 'text' or 'numeric'.
I will appreciate any advise!
0 Kommentare
Akzeptierte Antwort
James Tursa
am 2 Jul. 2016
if( isnumeric(X{1,end}) )
result = cell2mat(X);
else
result = cell2mat(X(:,1:end-1));
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!