How to remove spaces and special characters from elements of a char array
이전 댓글 표시
char array names = ['time (s)', 'speed (%)',....]
I want to save the char array such that () and % characters are removed, meaning names = ['time_s', 'accel_pedal',...]
댓글 수: 5
Paolo
2018년 8월 17일
Where is accel_pedal coming from? Do you mean speed_% ? Can you clarify what the logic is here?
Walter Roberson
2018년 8월 17일
Do you want to specifically remove only ( and ) and %, leaving in place anything like : or & ? Or do you have a specific set of characters you want to preserve with everything else to be changed or discarded?
If the input were 'time (s)' would you want the output to be 'time__s' or 'time_s' ?
Image Analyst
2018년 8월 17일
I'm sure you've tried strrep(), but what was wrong with that? And do you want to replace all "special" characters with underlines, like
str = strrep(str, '%', '_');
harshpurohit11
2018년 8월 18일
편집: harshpurohit11
2018년 8월 18일
Image Analyst
2018년 8월 18일
Yes you do. It was introduced before R2006a.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!