Loading text file with header and using Textscan yeilding empty array

I am unable to load data in txt file with header information using fopen and textscan. Below is the header type and the numeric data follows.
/datum 10000.00
/0057841A
/60Hz AC filter
/13.5V
/tune initialize N auto-tune Y 048.8uT
/time nT sq
000002.0 48812.27 99
000007.0 48812.26 99
000012.0 48812.27 99
000017.0 48812.31 99
000022.0 48812.26 99
I have tried using the following code but the data array has empty value irrespective of the last step. I know there's a silly error in my code. Would like to request for correction. Thanks in advance. One more question: How can I load this txt file in matlab and simply replace the '/' of header information with '%'?
fid=fopen('file.txt','r');
data=textscan(fid,'%f%f%d','HeaderLines',6);
data=cell2mat(data);

回答(1 个)

Your code works fine, not sure what is the problem.
Another way is to use importdata()
out=importdata('file.txt',' ',6)
str=strrep(out.textdata(:,1),'/','%')

类别

帮助中心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!

Translated by