【问题标题】:printmat without row labels in Matlab在 Matlab 中没有行标签的 printmat
【发布时间】:2014-07-15 10:18:19
【问题描述】:

我有一些矩阵,我想使用 printmat 打印它们。我只有它们的列名,所以我不需要行标签(我也不知道有多少行)。

所以我尝试了:

printmat(test,'test name','','test1 test2 test3 test4')

但它告诉我

Error using printmat (line 66)
Not enough row labels.

我现在能做什么?谢谢。

【问题讨论】:

  • 在检查新的 table 数据类型时可能值得您使用

标签: matlab


【解决方案1】:

您可以手动完成,但您需要设置数字格式和标签间距以匹配列。例如:

>> A = magic(4) %// example data

A =

    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

>> disp(['  test1     test2     test3     test4'; num2str(A, '%0.4f   ')])

  test1     test2     test3     test4
16.0000    2.0000    3.0000   13.0000
 5.0000   11.0000   10.0000    8.0000
 9.0000    7.0000    6.0000   12.0000
 4.0000   14.0000   15.0000    1.0000

请注意,不正确的间距可能会导致连接错误。必须手动设置间距。

顺便说一句,printmatseems to be obsolete

【讨论】:

  • 非常感谢! “...正确的间距可能会导致连接错误”这是什么意思?
  • @Natalia 我的意思是:例如,如果你在字符串' test1...' 中引入一个额外的空格,结果将不会简单地对齐错误;它根本不会显示(你不能垂直连接不同长度的字符串)
  • @Natalia 没错。或者你可以编写代码来自动完成,但这有点棘手
  • 这似乎有点不方便..顺便说一句,我必须num2str吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-24
  • 1970-01-01
  • 2018-11-15
  • 2018-09-13
  • 2019-10-25
  • 1970-01-01
  • 2021-04-25
相关资源
最近更新 更多