use MATLAB to find the keywords in the TXT document, and save the data behind the keyword to be processed with Matlab .
I measured a set of data stored in TXT file, is a WiFi signal strength document, which we need to get the data, there is useless data, want to use MATLAB to find the key (SSID), the number behind the keyword stored up for post-processing analysis, such as, Get the signal strength data (that negative number) behind Ky. Ask the great God to advise what should do, or to the program, thank you!
1234567891011121314151617 |
fn =
‘my_data.txt‘
;
fid = fopen(fn,
‘r‘
);
R = [];
while
~feof(fid)
tl = fgetl(fid);
id = findstr(tl,
‘SSID‘
);
while
~feof(fid)
tl = fgetl(fid);
id = findstr(tl,
‘ky‘
);
if
~isempty(id)
dt = tl(id+
3
:id+
10
);
dt = strtok(dt);
R = [R; str2num(dt)];
end;
end;
end;
disp(R);
|
Ask
Thank you very much! I just tried, except that there is a place is perfect, I txt has 100 data, but out of 99, the first did not get out what is going on? I hope you can see it again.
Reply
12345678910111213 |
fn =
‘my_data.txt‘
;
fid = fopen(fn,
‘r‘
);
R = [];
while ~feof(fid)
tl = fgetl(fid);
id = findstr(tl,
‘ky‘
);
if
~isempty(id)
dt = tl(id+
3
:id+
10
);
dt = strtok(dt);
R = [R; str2num(dt)];
end;
end;
disp(R);
|
Use MATLAB to find the keywords in the TXT document, and save the data behind the keyword to be processed with MATLAB.