How can I use tables in older versions of Matlab?

Is there any function in MATLAB 2010 or below version to print the result (ex: some matrices) as tables? All I got from googling was a function table()

that only works in MATLAB version 2013 or higher. I have MATLAB 2010 in my machine and it is impractical to download a newer version as it is very large and I am in a hurry. Thank.

+2


source to share


3 answers


For Matlab 2012 and below versions

can use printmat

printmat(yourMatrix, 'yourMatrix', 'ROW1 ROW2 ROW3 ROW4 ROW5', 'COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5' );

      

or use

dataset({yourMatrix 'COLUMN1','COLUMN2','COLUMN3','COLUMN4','COLUMN5'}, ...
                'obsnames', {'ROW1','ROW2','ROW3','ROW4','ROW5'})

      



with reference: Show matrix with row and column labels

For Matlab 2012 and higher versions:

Use array2table which will convert the array to a table.

Example:

A = [1 4 7; 2 5 8; 3 6 9];

T = array2table(A)

T = 

    A1    A2    A3
    __    __    __

    1     4     7 
    2     5     8 
    3     6     9 

      

+2


source


How about using displaytable

from Matlab file exchange file: http://www.mathworks.co.uk/matlabcentral/fileexchange/33717-display-formatted-text-table-of-data

Here's an example pulled from the documentation:

Example 1 - Basic use

colheadings = {'number of projects','sales','profit'};
rowheadings = {'Jimmy Slick', 'Norman Noob'}
data = [3 rand(1) rand(1); 1 rand(1) rand(1)];

      

To format the first number on each line as decimal (% d), the second number% 16.4f, and the third as% 16.5E do the following:



wid = 16;
fms = {'d','.4f','.5E'};

      

In this case 16 would be the field width and ".5E" is what to use for the fms argument

fileID = 1;

displaytable(data,colheadings,wid,fms,rowheadings,fileID);

      

This is the formatted output:

            |number of projec |           sales |          profit 
Jimmy Slick |               3 |          0.4502 |    5.22908E-001 
Norman Noob |               1 |          0.9972 |    2.78606E-002 

      

+3


source


Hi, I'm not sure what this function you mean with table()

. I use:

uitable('Data', c_Output(2:end,2:end), 'ColumnName', c_Output(1,2:end),...
         'RowName', c_Output(2:end,1), 'Units', 'normalized',...
         'Position', [0.575 0.32 0.33 0.13]);

      

c_Output is a matrix containing my data and row / column names. The position is calculated from the bottom left corner. So Top right will be (1,1). You will need to manually adjust it for each chart / position. Don't know if there is a built-in function that converts a table to a "graph"

+2


source







All Articles