Combining a character array and matrix
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Conner Carriere
le 10 Fév 2021
Commenté : Conner Carriere
le 10 Fév 2021
I was wondering if there was a way to combine a char array and a matrix
I have this character array
MwC =
9×1 char array
'w'
'b'
'y'
'b'
'w'
'r'
'y'
'r'
'b'
and this matrix
newcoords =
1
2
3
4
5
6
7
8
9
I have tried something like [newcoords, MwC] but that does not work and it outputs weird symbols
I need to be able to do something like
combined(1,2)= 'w'
I am ok with changing 'w' into a variable if that would work better
0 commentaires
Réponse acceptée
Walter Roberson
le 10 Fév 2021
Your desired output is not clear.
MwC = [
'w'
'b'
'y'
'b'
'w'
'r'
'y'
'r'
'b'];
newcoords = (1:9).';
newcoords + string(MwC)
compose('%d %s', newcoords, MwC)
char(ans)
compose("%d %s", newcoords, MwC)
table(newcoords, MwC)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!