How can i convert number to letter?

2 views (last 30 days)
Cagri Polat
Cagri Polat on 18 Feb 2015
Answered: Jos (10584) on 18 Feb 2015
I have a long data sets which is like [1;4;12;3;15;2;.....;16]. I want to replace number to letter. Like 1=N 2=NN 3=NNE 4=SS 5=WSW.... How can i manage this in matlab;
Thank you already,
Cagri

Answers (1)

Jos (10584)
Jos (10584) on 18 Feb 2015
Take a look at cell arraysof strings. Use the number directly as indices into a cell array, or convert using some scheme (like 100=1, 234=2, -12=3) first.
num = [1 3 5 4 3 2 2 1] % num van be used as direct indices
words = {'A','B','CC','DDDD','EE'} % list of words
NumInWords = words(num) % output cell array

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!