Replacing special character 'É' to 'E'
42 ビュー (過去 30 日間)
その他の回答 (2 件)
Stephen23 2022 年 11 月 28 日
編集済み: Stephen23 2022 年 11 月 28 日
"Is there a Matlab function to replace the special characters (like 'É')"
You can call Python from MATLAB, and it can do the heavy-lifting:
inp = 'É';
baz = @(v)char(v(1)); % only need the first decomposed character.
out = baz(py.unicodedata.normalize('NFKD',inp)) % to remove diacritics.
John D'Errico 2022 年 11 月 28 日
編集済み: John D'Errico 2022 年 11 月 28 日
str = 'ABCDEFGHIJKÉÉÀÀÄÄabcdefghijkl'
If there are other special characters you want replaced, strrep will handle them too, but it looks like you would need to do them one at a time with strrep. But other tools would certainly work too. Certainly regexp, but I've never been very good at regular expressions. :) This will work though:
badchar = 'ÉÀÄ';
goodchar = 'EAA';
[u,v] = ismember(str,'ÉÀÄ');
str(u) = goodchar(v(u))