Unable to extract data between two lines from a text file of below format
조회 수: 1 (최근 30일)
이전 댓글 표시
Text file is of below format
09:14.414] GPIB:ROUT:GPRF:MEAS:RFS:CONN RF1C
[09:14.416] ---Tx RF verify Measurement Results---
[09:14.417] LTE Path 47 Band 13 Not CA Frequency 180.0 Expected Power 23.0 50RB_Full RB Start Pos 0 BW 10.0 MHz Mod QPSK Tx Power 22.95 Limits 22 to 24 [dBm] Passed
[09:14.417] LTE Path 47 Band 14 Not CA Frequency 181.0 Expected Power 23.0 50RB_Full RB Start Pos 0 BW 10.0 MHz Mod QPSK EVM RMS 3.41 Limit 6 [%] Passed
[09:14.418] LTE Path 47 Band 15 Not CA Frequency 182.0 Expected Power 23.0 50RB_Full RB Start Pos 0 BW 10.0 MHz Mod QPSK EVM Peak 22.05 Limit 30 [%] Passed
[09:16.405] ---Performing Tx RF verify ended---
[09:17.388] FAIL: RS-RFV_Tx PostProcess
[09:17.392] --- End calibration ---
[09:17.392] Serial TX 'at@3,711 xns:!<\r><\n>'
Below is the code I have written to extract necessary data into an array. Index value( idx1 and idx2) it has shown is correct but data value is blank it didnt show any data in that variable.
fid = fopen('2018-09-26_11.08.16_18.26_trace_0.txt','r');
S = textscan(fid,'%s','Delimiter','\n');
S = S{1};
fclose(fid);
idxS1 = strfind(S, '---Tx RF verify Measurement Results---');
idx1 = find(not(cellfun('isempty', idxS1)));
idxS2 = strfind(S, '---Performing Tx RF verify ended---');
idx2 = find(not(cellfun('isempty', idxS2)));
data = cell2mat(cellfun(@str2num,S(idx1+1:idx2-1),'un',0)) ;
Can you pleas help to extract data between '---Tx RF verify Measurement Results---' and '---Performing Tx RF verify ended---' into an array
Also after that I need to get Tx power in one column and EVM RMS in one column
댓글 수: 2
답변 (2개)
Michael Madelaire
2019년 1월 2일
I do not know how you want the data. But you can very simply use
fgetl(fid)
to get a single line.
fid = fopen('example.txt');
fgetl(fid); fgetl(fid);
data = {};
for i = 1:3
tline = fgetl(fid);
data{i} = split(tline);
end
then you have a array containing each line split by a space-delimiter.
disp(data{1}); % to print a line
disp(data{1}(1)); % to show the first element in the first line
댓글 수: 4
Michael Madelaire
2019년 1월 3일
편집: Michael Madelaire
2019년 1월 3일
No, no it does not. Let's go back to the first piece of code.
"then you have a array containing each line split by a space-delimiter.
disp(data{1}); % to print a line
disp(data{1}(1)); % to show the first element in the first line
"
Now the data might not be in the format that you want. So let's go to my most resent comment.
"Next I do not understand what you means with extract data. That implies getting it in a specific format, which you have not given."
HOW DO YOU WANT THE DATA!!....
N/A
2019년 1월 3일
댓글 수: 1
Michael Madelaire
2019년 1월 3일
Yes it is more clear. But it is the third time you bring up more detail, making prior answers (that did what you asked for) waste of time.
I am out.
Best of luck.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!