Store value from text file
1 回表示 (過去 30 日間)
古いコメントを表示
So I have a text file and i need to store the sampling rate value like this:
samplingRate1 = 1000;
samplingRate2 = 2000;
I don't know how to find and store these values. The next thing is that the text file is very long but I only have to read the second line.
I tried using textscan but I am doing something wrong i think.
Any suggestions.
text file:
#kjkjj,lzddz;mzdm;dzm;mdz
# { {"sensor": ["CUSTOMV"], "device name": "00:07:80", "sampling rate": 1000, "position": 1, "sampling rate":2000, }}
#zffzfzvzgrgr
5502 0 0 11351 6478 7654 1936
3740 0 6594 6830 8041 5507 1 0 11281 6520 7608 1956
3741 0 6564 6797 8022 5608 2 0 11347 6446 7624 1909
3742 0 6543 6791 8046 5528 3 0 11272 6448 7591 1896
3743 0 6554 6776 8034 5570 4 0 11254 6395 7587 1948
3744 0 6544 6771 8028 5530 5 0 11259 6411 7602 1881
3745 0 6595 6752 8053 5587 6 0 11271 6408 7641 1944
........(keeps going)
0 件のコメント
採用された回答
Jalaj Gambhir
2020 年 5 月 19 日
Hi,
You can do so by:
s = fileread('test.txt'); % your text file's name
W = regexp(s,'"sampling rate":\s*([0-9]*)','tokens');
result = [W{:}].'
Also, to read a particular line number from a text file, you can refer to the solution provided here.
Hope this helps!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import and Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!