필터 지우기
필터 지우기

Importing 2 columns using textscan (OR possibly a different/easier way?)

조회 수: 7 (최근 30일)
Michael
Michael 2013년 11월 17일
편집: Michael 2013년 11월 17일
Hey MLC,
I'm trying to use texscan to get matrix output from files which have fourteen lines of junk header crap, and then 3 columns: the frequency, the data, and then another column (it's junk, though)
The files are named e.g. TEST2A.txt, TEST2B.txt, TEST3A.txt,...,TEST9A.txt, TEST9B.txt i.e. 'TEST' then '2'-'9' (labeled itest in my code) and then 'A'/'B' (this is called fileid) :)
How can I improve my code to peel off each column as (first:) freq{itest,fileid} and (second:) noise{itest,fileid}.. Please forgive my noobish ways, please correct me. Also, I tried ot use uiimport and I didn't know how it worked... feelin' dumb.
My code compiles and noise data is empty.
for itest=2:9; % Test Numbers
% two file-types "A" and "B"
filename{1}=sprintf('test%.0fA.txt',itest);
filename{2}=sprintf('test%.0fB.txt',itest);
% "A".. then "B"
for fileid=1:2
% File has 14 lines of header, then 3 col: freq, norm, phase
cll = textscan(filename{fileid},'numberofheaderlines',14);
noisedata{itest,fileid}=cell2mat(cll); clear cll
% freq = noisedata{itest,fileid}(:,1);
% noise = noisedata{itest,fileid}(:,2);
end;
end;
I appreciate your time.
Thank you, Michael

채택된 답변

Walter Roberson
Walter Roberson 2013년 11월 17일
cll = textscan(filename{fileid}, '%f%f%*f', 'numberofheaderlines', 14, 'CollectOutput', 1);
  댓글 수: 1
Michael
Michael 2013년 11월 17일
편집: Michael 2013년 11월 17일
As ALWAYS: your help is awesome, thanks a million!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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