如何在旧版本的Matlab中使用表格?

时间:2014-08-20 06:16:49

标签: matlab matlab-table

MATLAB 2010或以下版本中是否有任何函数以表格形式打印结果(例如:某些矩阵)?我从googling得到的只是一个table()函数,仅适用于MATLAB 2013或更高版本。我已经在我的机器上安装了MATLAB 2010,下载新版本并不实用,因为它非常大而且我很匆忙。谢谢。

3 个答案:

答案 0 :(得分:3)

如何使用Matlab文件交换中的displaytablehttp://www.mathworks.co.uk/matlabcentral/fileexchange/33717-display-formatted-text-table-of-data

以下是从文档中解除的一个例子:

示例1 - 基本用法

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

要将每行中的第一个数字格式化为十进制(%d),第二个 编号%16.4f,第三个编号为%16.5E,执行以下操作:

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

在这种情况下,16将是字段宽度,'。5E'是用于的字段宽度 fms论证

fileID = 1;

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

这是格式化的输出:

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

答案 1 :(得分:2)

对于Matlab版本2012及以下版本,

可以使用printmat

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

或使用

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

参考:Display matrix with row and column labels

对于Matlab版本2012及更高版本:

使用array2table,将数组转换为表格。

示例:

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 :(得分:2)

您好我不确定您是否认为table()的功能。我正在使用的是:

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是一个包含我的数据和行/列名称的矩阵。该位置从左下角开始计算。所以右上角是(1,1)。您必须手动调整每个图形/位置。不知道是否存在将表格转换为"剧情的功能#34;