Unable to extract data between two lines from a text file of below format

2 views (last 30 days)
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

Answers (2)

Michael Madelaire
Michael Madelaire on 2 Jan 2019
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 Comments
N/A
N/A on 3 Jan 2019
I tried running the code. Now its showing array size instead of actual data in the variable data as shown in the attached figure.
Michael Madelaire
Michael Madelaire on 3 Jan 2019
Edited: Michael Madelaire on 3 Jan 2019
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!!....

Sign in to comment.


N/A
N/A on 3 Jan 2019
I have attached the text file which we are giving as input and an excel that will give an idea on the format how array need to be. Hoping this would give more clarity. Let me know if it is still not clear.
  1 Comment
Michael Madelaire
Michael Madelaire on 3 Jan 2019
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.

Sign in to comment.

Categories

Find more on File Operations in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!