Find ascii numbers from cells
4 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Adam Danz
2021-1-23
编辑:Adam Danz
2021-1-23
Matlab stores characters as Unicode characters which incorporates the ASCII character set as the first 128 sumbols.
Convert characters -->Unicode/ASCII using double('__')
Convert Unicode/ASCII-->characters using char(__)
double('a')
double('Matlab')
char([77 97 116 108 97 98])
double('😎') % Not ASCII
To apply that to a cell array,
z = {'Here','is an','example','!',''};
a = cellfun(@double, z, 'UniformOutput', false)
a{1} % "Here"
a{2} % "is an"
--or--
v = cell2mat(cellfun(@double, z, 'UniformOutput', false))
Put the cell array of ASCII codes back into char vector
c = strjoin(cellfun(@char, a, 'UniformOutput', false))
3 个评论
Adam Danz
2021-1-23
How are you reading in the file
C = readcell('names.xlsx');
a = cellfun(@double, C, 'UniformOutput', false)
% a =
% 7×1 cell array
% {1×4 double}
% {1×6 double}
% {1×6 double}
% {1×4 double}
% {1×4 double}
% {1×3 double}
% {1×7 double}
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!