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

1 Ansicht (letzte 30 Tage)
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

Antworten (2)

Michael Madelaire
Michael Madelaire am 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 Kommentare
N/A
N/A am 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 am 3 Jan. 2019
Bearbeitet: Michael Madelaire am 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!!....

Melden Sie sich an, um zu kommentieren.


N/A
N/A am 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 Kommentar
Michael Madelaire
Michael Madelaire am 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by