从文本文件中读取并将其加载到Matlab中的矩阵中 [英] read from a text file and load it into a matrix in matlab

查看:1002
本文介绍了从文本文件中读取并将其加载到Matlab中的矩阵中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件,名为以下坐标格式:

I have a text file called coordinates.txt as following format:

0 0 0
-0.95 0.32 -0.02
-1.02 0.26 -0.96
-0.73 0.6 -0.52
-0.77 0.6 -0.71
-0.28 0 -0.95
-0.14 -0.16 0.13
-0.46 -1 -0.29
-1.14 -0.6 0.16

如何使用命令将其加载到matlab中并将其保存在名为X的矩阵中,如下所示:

How could I load it in matlab with commands and save it in a matrix called X as following:

X=[0 0 0;
-0.95 0.32 -0.02;
-1.02 0.26 -0.96;
-0.73 0.6 -0.52;
-0.77 0.6 -0.71;
-0.28 0 -0.95;
-0.14 -0.16 0.13;
-0.46 -1 -0.29;
-1.14 -0.6 0.16;]

因此文本文件中的每一行都将保存为矩阵X中的一行.

so each line in the text file will be saved as a row in matrix X.

推荐答案

S = load('coordinates.txt', '-ascii');

键入帮助负载"以获取更多信息.

Type 'help load' for more information.

这篇关于从文本文件中读取并将其加载到Matlab中的矩阵中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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