how to print two matrices side by side

20 views (last 30 days)
I have two matrices which have different number of rows and I want to print them side by side (better with column labels). For example, I have
>> test
test =
12 13
1 14
1 14
>> test2
test2 =
14 88
1 66
I want to get something like
label1 label2 label3 label4
12 13 14 88
1 14 1 66
1 14
How can I do that? Thanks a lot!

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 15 Jul 2014
Edited: Azzi Abdelmalek on 15 Jul 2014
You can't create such thing, unless you complete a matrix with 0 or whatever you want, you can also use cells
test =[ 12 13; 1 14; 1 14]
test2=[14 88; 1 66]
[n,m]=size(test)
[n2,m2]=size(test2)
nn=max(n,n2)
out=cell(nn,m+m2)
out(1:n,1:m)=num2cell(test)
out(1:n2,m+1:end)=num2cell(test2)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!