Use MATLAB to find the keywords in the TXT document, and save the data behind the keyword to be processed with MATLAB.

Source: Internet
Author: User
Tags strtok

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.