How to convert decimals to Ascii characters?
이전 댓글 표시
So I have a char with a bunch of decimals in each line, these decimals go from 0 to 63. I'm trying to convert these decimals to the one that represents it in the image below. So 0 should be changed to A, 1 should be changed to B and so on. Anyone know if there are some functions to make this easier?

채택된 답변
추가 답변 (1개)
Your table isn't ASCII encoding of characters, so you can't use simple functions such as double( ) etc. You are probably going to have to write your own conversion function. I would suggest looking at the ismember( ) function using the 2nd Locb output. E.g. start with this char string:
S = ['A':'Z','a':'z','0':'9','+','/']
Then you can use this for mapping back & forth between the numbers and the characters, offsetting the index by 1. E.g.,
c = 'THEstring'
[~,N] = ismember(c,S); % From char string to numbers
x = N-1 % Offset by 1
C = S(x+1) % From numbers back to char string, offset by 1
It would also help if you provided example inputs and desired outputs in your question so we know exactly what you want.
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!