how to covert char array to num array?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mithushan Kanthasamy
am 22 Feb. 2021
Kommentiert: Walter Roberson
am 23 Feb. 2021
how do i convert char array to num array?
arr = ['some'; 'thee'; 'time'; 'hour']
I need a way to convert into the ascii values of these char.
2 Kommentare
Walter Roberson
am 23 Feb. 2021
The original version had 'the' instead of 'thee' so it could not be represented as a character array... which is why David answered with {}
Akzeptierte Antwort
David Hill
am 22 Feb. 2021
arr={'some'; 'the'; 'time'; 'hour'};%must be cell array since lengths are not the same
for k=1:length(arr)
arr{k}=double(arr{k});%simple for-loop converts
end
2 Kommentare
Walter Roberson
am 22 Feb. 2021
No. The best you can do is hide the loop
output = cellfun(@double, arr, 'uniform', 0)
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!