如何在Octave中漂亮地打印矩阵? [英] How to pretty print a matrix in Octave?

查看:243
本文介绍了如何在Octave中漂亮地打印矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从矩阵(或列向量)创建漂亮的打印表. 对于Matlab,有几个可用的函数可以做到这一点(例如 printmat,array2table table),但是对于Octave,我找不到任何函数.

I want to create a pretty printed table from a matrix (or column vector). For Matlab there are several available functions that can do this (such as printmat, array2table, and table), but for Octave I cannot find any.

所以代替:

>> a = rand(3,2)*10;
>> round(a)
ans =

    2   10
    1    3
    2    1

我想看看:

>> a = rand(3,2)*10;
>> pretty_print(round(a))

   THIS   THAT
R1    2   10
R2    1   3
R3    2   1

如何从矩阵生成漂亮的打印表?
(有可用的软件包吗?)

How can I produce a pretty printed table from a matrix?
(Any available package to do so?)

更新

尝试按照Octave Wiki的极其晦涩的软件包安装说明进行操作后,我不断收到错误 pkg: failed to read package 'econometrics-1.1.1.tar.gz': Couldn't resolve host name .显然Windows版本无法使用直接安装命令(如其Wiki上所给出).我设法得到它的唯一方法是,先将软件包手动下载到Octave的当前工作目录中. (请参见pwd输出.)只有然后才能执行安装命令.

After trying to follow the extremely obtuse package installation instruction from Octave Wiki, I kept getting the error pkg: failed to read package 'econometrics-1.1.1.tar.gz': Couldn't resolve host name. Apparently the windows version isn't able to use the direct installation command (as given on their Wiki). The only way I managed to get it, was by first downloading the package manually into the current working directory of Octave. (See pwd output.) Only then did the install command work.

pkg install econometrics-1.1.1.tar.gz
pkg load econometrics

推荐答案

是的,有一个 econometrics 中的"> prettyprint 函数一个>包.一旦安装并加载了软件包,就可以像这样使用它:

Yes, there is a prettyprint function in the econometrics package. Once the package is installed and loaded, you can use it like this:

>> a = rand(3,2)*10;
>> prettyprint(round(a),['R1';'R2';'R3'],['THIS';'THAT'])

          THIS        THAT
R1       2.000       3.000
R2       3.000       4.000
R3      10.000       3.000

这篇关于如何在Octave中漂亮地打印矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆