How can i convert number to letter?

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)

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

Asked:

on 18 Feb 2015

Answered:

on 18 Feb 2015

Community Treasure Hunt

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

Start Hunting!