# Combine Text and number in a matrixs

9 views (last 30 days)
aymeric neige on 1 Nov 2020
Answered: Ameer Hamza on 1 Nov 2020
Hi, I have a simple question about a script that i wrote.
My problem is this:
I have 4 matrice : A B C D and each of them has (10x1 cells).
I want to combine text and number in a matrixe like:
'A' 'B' 'C' 'D'
2 3 4 5
4 5 6 7
... ... ... ...
so i wrote this one :
Total = [{'LLO'},LLO;{'LLF'},LLF;{'RLO'},RLO;{'RLF'},RLF]';
but when i run it i have :
'A' 'B' 'C' 'D'
(2,4,...) (3,5,...) (4,6,...) (5,7,...)
As i want to export my matrix to excel, i can't.
Any Ideas ?

Ameer Hamza on 1 Nov 2020
Try something like this
LLO = randi([1 10], 1, 10);
LLF = randi([1 10], 1, 10);
RLO = randi([1 10], 1, 10);
RLF = randi([1 10], 1, 10);
result = [{'LLO', 'LLF', 'RLO', 'RLF'}; num2cell([LLO(:), LLF(:), RLO(:), RLF(:)])]
Result
>> result
result =
11×4 cell array
{'LLO'} {'LLF'} {'RLO'} {'RLF'}
{[ 1]} {[ 1]} {[ 4]} {[ 10]}
{[ 9]} {[ 4]} {[ 10]} {[ 10]}
{[ 9]} {[ 7]} {[ 3]} {[ 6]}
{[ 6]} {[ 9]} {[ 6]} {[ 2]}
{[ 8]} {[ 7]} {[ 8]} {[ 4]}
{[ 6]} {[ 7]} {[ 3]} {[ 3]}
{[ 6]} {[ 7]} {[ 9]} {[ 3]}
{[ 2]} {[ 8]} {[ 6]} {[ 3]}
{[ 6]} {[ 7]} {[ 10]} {[ 1]}
{[ 1]} {[ 6]} {[ 4]} {[ 9]}

madhan ravi on 1 Nov 2020
Wanted = {'A' 'B' 'C' 'D'
2 3 4 5
4 5 6 7} % as cell array
Wanted = 3x4 cell array
{'A'} {'B'} {'C'} {'D'} {} {} {} {} {} {} {} {}
aymeric neige on 1 Nov 2020
ok it work but instead of 2,3,4,5 (example) i have matrix : RLL LLL RUL LUF.
Each of it has 10 cells and i don't want to write them one-by-one. So that commande
wanted = {'A' 'B' 'C' 'D'
RLL LLL RUL LUF}
doesn't work and i have the same issue.