how to remove multiple string line from ascii data file

hello,
I have model output in ascii format which contains multiple strings that i want to remove. here I paste some of data with string lines.
194397 479 23:50:00 3.287000E-03 1.824640E+04 1.824640E+04 1.333954E+16
194398 479 23:53:20 3.287000E-03 1.824640E+04 1.824640E+04 1.333954E+16
194399 479 23:56:40 3.287000E-03 1.824640E+04 1.824640E+04 1.333954E+16
194400 480 00:00:00 3.287000E-03 1.824640E+04 1.824640E+04 1.333954E+16
DEF_HIS - creating history file: output/rmed16_grd_e/GLS/his_rmed16_grd_gls_0451.nc
DEF_AVG - creating average file: output/rmed16_grd_e/GLS/avg_rmed16_grd_gls_0015.nc
WRT_AVG - wrote averaged fields into time record = 0000001
DEF_DIAGS - creating diagnostics file: /output/rmed16_grd_e/GLS/dia_rmed16_grd_gls_0450.nc
194401 480 00:03:20 3.286999E-03 1.824640E+04 1.824640E+04 1.333954E+16
194402 480 00:06:40 3.286997E-03 1.824640E+04 1.824640E+04 1.333954E+16
194403 480 00:10:00 3.286996E-03 1.824640E+04 1.824640E+04 1.333954E+16
194404 480 00:13:20 3.286994E-03 1.824640E+04 1.824640E+04 1.333954E+16
so please tell me how can do it.
thanks
mahesh

回答 (1 件)

Jan
Jan 2011 年 7 月 20 日

1 投票

FID = fopen(FileName, 'r');
C = textscan(FID, '%s', 'Delimiter', '\n');
S = C{1};
[dummy, index] = sort(S);
keep = false(1, numel(S));
keep(index) = true;
UniqueS = S(keep);
The variable dummy contains the sorted list of unique lines. But more likely you want the list in the original order.

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2011 年 7 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by