R&S waveform (.wv) files read and write!
56 views (last 30 days)
Show older comments
huachuca
on 30 Dec 2024 at 20:55
Hello,
How would I read and create R&S waveform (.wv) files? I am not refering to wav sound files by the way. Thanks.
4 Comments
Cris LaPierre
on 31 Dec 2024 at 13:25
Can you share a sample file? You can zip it and attach it to your post using the paperclip icon.
You might find the approach taken in this Answers post helpful. It's a different file type, but I imagine the solution here would look very similar.
Cris LaPierre
on 31 Dec 2024 at 14:45
I wouldn't expect it to work as is. You need to adapt it to your file type. That means using the correct bit order, data type and format of the *.wv file. This page may offer a starting point: https://www.rohde-schwarz.com/us/applications/converting-r-s-i-q-data-files-application-note_56280-35531.html
Accepted Answer
Cris LaPierre
on 31 Dec 2024 at 19:11
Your file format is definitely different. Rather than being all binary, like the example I linked to, it captures the binary data in the waveform data field. The file format looks like this
It's going to take a mixed approach to extract the data.
Since you haven't provided the file format description, I did a quik look. The waveform data appears to be captured as int16 values stored in little endian format. This code can read the file you have shared.
unzip('BPSK.zip')
% Define the filename
filename = 'BPSK.wv';
% Open the file for reading
fileID = fopen(filename, 'r');
c = 2;
pos(1) = 0;
while ~feof(fileID)
[data, pos(c)] = textscan(fileID,'%s',1,'Delimiter',{'{','}'},'MultipleDelimsAsOne',true);
token = data{1};
switch true
case contains(token,'TYPE')
str = split(token,':');
type = str(2);
case contains(token,'CLOCK')
str = split(token,':');
clock = str2double(str(2));
case contains(token,'LEVEL OFFS')
str = split(token,{':',','});
leveloffs = str2double(str(2:end))';
case contains(token,'WAVEFORM-')
str = split(token,'#');
L = str2double(extract(str{1},digitsPattern))-1;
fseek(fileID,pos(c-1)+length(str{1})+1,'bof');
wv = fread(fileID,[2,L/2],'int16','ieee-le');
wv = wv.*(wv<0)./32768 + wv.*(wv>=0)./32767;
I = wv(1,:);
Q = wv(2,:);
end
c=c+1;
end
fclose(fileID);
t = 0:1/clock:(length(I)-1)/clock;
tiledlayout(2,1)
nexttile
plot(t,I)
nexttile
plot(t,Q)
1 Comment
More Answers (0)
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!