lundi 2 mars 2015

Replace numbers with string in matlab array

I have an array of numbers in MATLAB eg.,



a = [1 1 1; 2 2 1; 3 3 2; 4 5 1];


and I would like to replace the numbers with strings.


eg., 1= "apples"; 2= "hello"; 3 = "goodbye";


I can for example replace with other numbers eg.,



a(a==1) = 999
a(a==2) = 998


but I need to accomplish the same kind of thing by replacing with string. Not easy to me can someone help me out ? Thanks, Matilde


Aucun commentaire:

Enregistrer un commentaire