필터 지우기
필터 지우기

Code help for data extraction

조회 수: 1 (최근 30일)
Nakarsha
Nakarsha 2014년 3월 22일
답변: Image Analyst 2014년 3월 22일
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!!

답변 (2개)

Gareth Thomas
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?

Image Analyst
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.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by