フィルターのクリア

How do a textscan to read the value in the line above the strmatch

2 ビュー (過去 30 日間)
Rafael Freire
Rafael Freire 2011 年 6 月 27 日
How can i read the value of sw in the line above of strmatch
vtwait 3 1 14 14 14 2 1 8194 1 64
1 300
0
tpwr 7 1 17 17 17 2 1 8194 1 64
1 50
0
sw 1 1 5 5 5 2 1 8203 1 64
1 4801.92076831
0
sfrq 1 1 1000000000 0 0 2 1 11 1 64
1 499.4240618
0
sc2 1 1 3 3 3 4 1 8195 1 64
1 0
0
sbs1 1 1 1000 -1000 0.001 3 1 1 0 64
1 0
0
use this command line head0=textread(file,'%s'); sf=str2num(char(head0(strmatch('sfrq ',head0')+2))) The value for that is '1' but i want the value '499.4240618' in the line above
  1 件のコメント
Oleg Komarov
Oleg Komarov 2011 年 6 月 28 日
I would rathr skip the passage with head0 and go directly with textscan as I showed below.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2011 年 6 月 27 日
I think you mean "the line below" not "the line above"
sw=str2num(char(head0(strmatch('sfrq ',head0')+12)));
  1 件のコメント
Rafael Freire
Rafael Freire 2011 年 6 月 28 日
Yes it´s really the line below. Sory and thank you

サインインしてコメントする。

その他の回答 (1 件)

Oleg Komarov
Oleg Komarov 2011 年 6 月 27 日
fid = fopen('C:\Users\Oleg\Desktop\test.txt');
out = textscan(fid,'%s%f%f%f%f%f%f%f%f%f%f\r\n%f%f\r\n%f','CollectOutput',1);
fid = fclose(fid);
out{2}

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by