如何使用txt2mat跳过列 [英] How to skip a column using txt2mat
本文介绍了如何使用txt2mat跳过列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在matlab中导入一些csv文件,但是csvread太慢了.
I´m trying to import some csv files in matlab, but csvread is too slow.
我正在使用txt2mat,但我不知道如何跳过导入中的第一列.
I´m using txt2mat, but i don´t know how to skip the first column in the import.
这是我尝试的方式
myimportedfile = txt2mat(myfile,'ReadMode','block',1) %im skipping the headers too.
我需要跳过的原因是因为第一列是非数值数据.
The reason i need to skip is beacause the first column is non-numerical data.
有没有办法使用txt2mat做到这一点?还是有更好的办法?
Is there a way to do this with txt2mat or is there a better way?
先谢谢.
推荐答案
textscan 使您能够跳过列.它使用类似于 fprintf 的格式字符串读取数据.
textscan gives you the ability to skip columns. It reads in data using an fprintf-like format string.
示例文件:
Val1 Val2 Val3
1 2 3
4 5 6
7 8 9
代码:
tmp = textscan('example.txt', '%i %*i %i') % the * indicates fields to ignore
tmp{:}
这篇关于如何使用txt2mat跳过列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文