Code help for data extraction
2 次查看(过去 30 天)
显示 更早的评论
Need a code allowing me to input a txt file then search for data corresponding with a given number. For example, in my file there are 20 sets of data containing over 5000 different values in a set. I have the data save in the txt file in two columns. In the end I need to be able to import several different data files and then extract values at a given point. PLEASE HELP ME!!
0 个评论
回答(2 个)
Gareth Thomas
2014-3-22
Hi Nakarsha,
There are multiple ways of doing this.
Use the Import Tool - in MATLAB, select the text file, right click, import data.
In this tool you can create a script or function (see the Import Selection on the right, click on the little arrow down), which will code the automatically for you this process. You now have a variable in MATLAB, then all you need to do is add to the atomically script what you want.
Probably you will use something like logical indexing to get the values.
In your example you will have multiple files, with data, then all you need to do is a:
a = dir
And get all the txt files, write a for loop, call the function/script you created and continue with your work.
Does this help?
0 个评论
Image Analyst
2014-3-22
The best way is to use readtable() , but that requires R2013b or later. Failing that, if you have a really old version, use csvread(), dlmread(), importdata(), fgetl() and sscanf(), textscan() or something like that.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!