Make arrays into a table

Hi,
I have 6 arrays of equal length, each representing a certain parameter and each slot in the array represents the value of the parameters
I would like to tabulate the data so that I can scroll through and see all the data at once. How may I do this?
The image below is what I am looking for, ideally where I can specify a label in the left most column.

Answers (2)

Chunru
Chunru on 3 Sep 2021
Edited: Chunru on 3 Sep 2021
It's better to organize the table in transposed order.
a1 = rand(10, 1);
a2 = rand(10, 1);
a3 = rand(10, 1);
T = table(a1, a2, a3)
T = 10×3 table
a1 a2 a3 ________ _______ ________ 0.019949 0.95707 0.72243 0.034856 0.37661 0.028956 0.055403 0.27985 0.43342 0.7962 0.20116 0.36953 0.61853 0.41453 0.95966 0.14751 0.29902 0.60573 0.23709 0.94669 0.016313 0.76907 0.69757 0.70434 0.54518 0.43477 0.2681 0.13691 0.83177 0.14211
plot(T.a1)

4 Comments

Ohh wow, it is that easy, thank you! It doesn't make a huge amount of difference to me, but say if I wanted to plot the table in the orientation I showed in my original post, how may I go about this?
use plot(T.a1), for example.
I've just tried your solution with my arrays and It just shows me the headings an says "1x12 double" instead of listing the 12 data points.
In that case, you may need to transpose your data first before forming the table. See the size of the variables a, b, c.

Sign in to comment.

TOK, you have 6 series, each with length 10. The normal way to orient that would be 10 rows, 6 columns. Nonetheless,
>> a1 = rand(1,10);
>> a2 = rand(1,10);
>> a3 = rand(1,10);
>> T = array2table([a1;a2;a3])
T =
3×10 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10
_______ ________ _______ ________ ________ _______ _______ _______ _______ ________
0.70605 0.031833 0.27692 0.046171 0.097132 0.82346 0.69483 0.3171 0.95022 0.034446
0.43874 0.38156 0.76552 0.7952 0.18687 0.48976 0.44559 0.64631 0.70936 0.75469
0.27603 0.6797 0.6551 0.16261 0.119 0.49836 0.95974 0.34039 0.58527 0.22381
But if you want to plot each series as one line, that's the wrong orientation to use, as Chunru showed..

Categories

Products

Release

R2020a

Asked:

TOK
on 3 Sep 2021

Answered:

on 2 Mar 2022

Community Treasure Hunt

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

Start Hunting!