Effacer les filtres
Effacer les filtres

Can I combine letters with numbers in the same matrix?

3 vues (au cours des 30 derniers jours)
M
M le 23 Août 2022
Commenté : Steven Lord le 23 Août 2022
Can I combine letters with numbers in the same matrix?
I have vector B return two letters for example [L M]
And another vector O returns two numbers for example [1 2]
Can I combine them to be like this?
[L M
1 2]

Réponse acceptée

Rik
Rik le 23 Août 2022
You have these options:
{'L','M';1,2}
ans = 2×2 cell array
{'L'} {'M'} {[1]} {[2]}
["L","M";"1","2"]
ans = 2×2 string array
"L" "M" "1" "2"
['L','M';1,2]
ans = 2×2 char array
'LM' ''
double(['L','M';1,2])
ans = 2×2
76 77 1 2
  1 commentaire
Steven Lord
Steven Lord le 23 Août 2022
Another option:
T = table(['L'; 'M'], [1; 2])
T = 2×2 table
Var1 Var2 ____ ____ L 1 M 2
T(1, :)
ans = 1×2 table
Var1 Var2 ____ ____ L 1

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays 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!

Translated by