how to delete specific raw from text file ?
1 回表示 (過去 30 日間)
古いコメントを表示
I want to open this text file and delete each row from a file which starts with charachter F,D and N.after that i want to make a simple mat file with remaining data. any help will be helpful. thanks.
0 件のコメント
採用された回答
Ameer Hamza
2018 年 5 月 15 日
編集済み: Ameer Hamza
2018 年 5 月 15 日
You can read the file and delete these rows like this
f = fopen('04.txt');
data = textscan(f, '%s', 'Delimiter', '\n');
fclose(f);
data = data{1};
rowsToDelete = startsWith(data, {'F', 'N', 'D'});
% rowsToDelete = cellfun(@(x) any(x(1) == 'FND'), data); % for older version than R2016b
data(rowsToDelete) = [];
the variable data will contain all the remaining rows as char array. Since all these rows contain mix datatypes i.e. characters and numbers and a variable number of elements. it is not clear how do you want your final data in the numeric form.
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!