Find ascii numbers from cells
์กฐํ ์: 4 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
Ivan Mich
2021๋
1์ 23์ผ
I would like to find ascii numbers from cells. My file has words/letters (cell arrays). I would like to calculate ascii number for each cell.
Could you help me please?
๋๊ธ ์: 0
์ฑํ๋ ๋ต๋ณ
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!