How to reformat a matrix with a continuous string

1 Ansicht (letzte 30 Tage)
Moe
Moe am 22 Feb. 2016
Beantwortet: dpb am 22 Feb. 2016
Matrix A is as follows:
A = [7843,20,21,22,24,21;2345,21,23,22,24,25;5452,21,20,22,24,25;4231,20,21,22,23,20];
First convert 20 to A, 21 to B, 22 to C, 23 to D, 24 to E, 25 to F
I want matrix A to be formed like:
B = ['7843','ABCEB'
'2345','BDCDE'
'5452','BACDE'
'4231','ABCDA'];
  • I need this format for using in Align multiple sequences, link below:
Or like the following photo:

Akzeptierte Antwort

dpb
dpb am 22 Feb. 2016
>> B=[cellstr(num2str(A(:,1))) cellstr(char(A(:,2:end)+'A'-20))]
B =
'7843' 'ABCEB'
'2345' 'BDCEF'
'5452' 'BACEF'
'4231' 'ABCDA'
>>

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by