Assigning alphabets to a range of numbers.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have an array of random numbers. I want to assign alphabets to a range of numbers. For example 0-20 should be assigned letter A and so on. Kindly help me how to do this.
Risposte (2)
Guillaume
il 5 Ott 2016
Modificato: Guillaume
il 5 Ott 2016
Your question is really not clear. Possibly:
v = randi([0 20*26-1], 1, 20) %vector of random number
bins = 0:20:20*26; %[0-19] is A, [20-39] is B, etc. the bins don't have to be uniform but they have to be continuous
out = char(discretize(v, bins) + 'A' - 1)
2 Commenti
Walter Roberson
il 5 Ott 2016
letter(i) = 'A';
You cannot store letters and numeric values in the same numeric (or character) array.
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!