필터 지우기
필터 지우기

Header seperation and column matching

조회 수: 1 (최근 30일)
Ormo
Ormo 2012년 12월 18일
I have made a program which imports text data with dates and headers turns it into a matrix and plots using the date column as X axis and selectively each other data column for Y axis. The problem is that the header line appears to be as one string. How do I seperate it into many strings and how can I use them to automatically match each corresponding data column name? For example if one of the strings is "radiation" , when I type radiation the radiation data column should view.

답변 (1개)

John Petersen
John Petersen 2012년 12월 18일
Suppose your file has a header like
radiation, temperature, voltage
data....
Then your program would get the header with
fid = fopen(yourfile);
currentline = fgetl(fid); % gets the first line of the file
col = 0;
nextind = 1;
while (currentline >0)
col = col + 1;
[parm{col}, count, errmsg, nextind] = sscanf(currentline(nextind:end),'%s,');
end
parm is a cell array that contains all your header parameters.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by