remove variables in txt file
2 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I have trouble in removing first line in txt file, remove () , in txt file and split into three vectors.
fnm1 = 'p_s.txt ';
E = load(fnm1);
t=E(:,1);
v=E(:,2);
someone plese help me out?
0 个评论
采纳的回答
Ilian
2020-4-7
You could remove the header line first with something like this:
fileID = fopen('p_s.txt');
dataFormat = '%f %s';
C_text = textscan(fileID,dataFormat,'HeaderLines',1,'Delimiter','\t');
t = cell2mat(C_text(1));
And then use regexp to get the numerical values from the second column
1 个评论
Ilian
2020-4-7
There is for sure a better solution to this, but If you just want something that works, you can just add a few extra delimiters
fileID = fopen('p_s.txt');
dataFormat = '%f (%f %s %s %f %s';
C_text = textscan(fileID,dataFormat,'HeaderLines',1,'TreatAsEmpty',{'d'},'Delimiter','\tdB,)');
t1 = cell2mat(C_text(1));
t2 = cell2mat(C_text(2));
t3 = cell2mat(C_text(5));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!