Consider the following text file file:

考虑以下文本文件:

1 2 3
4 5 6
7 8 9

I would like to have linux command writemat that does the following:

我想要linux命令writemat执行以下操作:

$ writemat --size=3,3 --outputFile=m.mat --name=A <file

producing a matlab .mat file m.mat, such that I can later do from within Matlab:

生成一个matlab .mat文件m.mat,这样我以后可以在Matlab中做:

>> s=load('m.mat')

s = 

    A: [3x3 double]

>> s.A

ans =

     1     2     3
     4     5     6
     7     8     9

Does such a command exist? Or do I have to write my own using the Matlab Application Programming interfaces? However, the latter feels somewhat like reinventing the wheel..

这样的命令存在吗?或者我是否必须使用Matlab应用程序编程接口编写自己的应用程序?然而,后者感觉有点像重新发明轮子..

1 个解决方案

#1


1

This is not exactly what you want, but it may be equivalent: In Matlab you can load an ASCII file (like that in your example) using

这不是你想要的,但它可能是等价的:在Matlab中你可以加载一个ASCII文件(就像你的例子中那样)

load(name,'-ascii')

where name is a string containing the file name. The file contents are read into a Matlab variable with the same name as the file.

其中name是包含文件名的字符串。文件内容被读入与文件同名的Matlab变量。


If you need several variables in the same file, you could write the ASCII file as

如果在同一文件中需要多个变量,则可以将ASCII文件写为

a=[
1 2 3
4 5 6
7 8 9];
b=[
0 1 0 1];

(that is, add variable names and [, ], ; signs), and then run it from Matlab.

(即添加变量名称和[,],;符号),然后从Matlab运行它。

更多相关文章

  1. Debian下环境变量设置
  2. arm-linux学习笔记3-linux内存管理与文件操作
  3. 我应该在哪里添加Yocto位烤任务来创建工作文件夹符号链接?
  4. CENTOS 修改MYSQL文件到内存盘
  5. Scientific Linux:我需要获取一个shell脚本变量并使用它来搜索awk
  6. 用另外两个文件过滤一个文件
  7. Linux系统下 使用Lsof恢复误删除的文件
  8. Linux 的文件类型
  9. C语言文件I/O 读取一个文件并输出出来 和 输出到另一个文件里面

随机推荐

  1. Xml序列化的图文代码详解
  2. XML学习(三) js保存xml的示例代码分享
  3. XML串行化的示例代码分享
  4. 详细介绍XML操作总结的示例代码
  5. 使用xlst将xml转换html的示例代码
  6. XML实战秘籍第四卷:选单连动
  7. XML学习(二)详解DOM操作XML文档
  8. XML实战秘籍第三卷:动态分页
  9. XML学习(一)元素,属性,读取详解
  10. XML实战秘籍第二卷:动态查询