Combine Text and number in a matrixs
13 views (last 30 days)
Show older comments
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 ?
0 Comments
Answers (2)
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]}
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!