Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

Matlab - Save in WFM format

Questions in this forum area are community supported. Tektronix does not regularly monitor or guarantee responses in this area.
Post Reply
azham
Posts: 7
Joined: May 30th, 2013, 12:58 am

Matlab - Save in WFM format

Post by azham » June 9th, 2014, 12:35 am

Hi,

I would like to know any codes available to save WFM format in MATLAB
I've tried finding on the net but none available

Azham

Carl M
Tektronix Applications
Tektronix Applications
Posts: 796
Joined: July 30th, 2008, 4:45 pm
Country: United States

Re: Matlab - Save in WFM format

Post by Carl M » June 9th, 2014, 11:49 am

i think you are looking for: http://www1.tek.com/forum/viewtopic.php?f=6&t=2555
this is part of the code examples sticky: http://www1.tek.com/forum/viewtopic.php?f=8&t=1789
Tektronix Application Engineer

azham
Posts: 7
Joined: May 30th, 2013, 12:58 am

Re: Matlab - Save in WFM format

Post by azham » June 10th, 2014, 11:47 pm

I've tried the code given. Failed to open in ArbXpress.

I checked the output and compared with a correct .wfm

So i've tweak abit so it save properly.
The data needs to be in binary and \n seems to create a new line in the data

Hope it helps anyone trying to find this

Code: Select all

%% variables
samples = 262000; 
filename = 'O_262Kpts.WFM';
count = 1;
%% create test waveform 
wave = -2.*rand(samples, 1)+1; 
sample_bytes = num2str(samples*5,'%d');
length_bytes = num2str(length(sample_bytes)); 
header = ['#' length_bytes sample_bytes]; 
%% file operations 
fid = fopen(filename, 'wt'); 
fwrite(fid, 'MAGIC 1000');
fprintf(fid, '\n');
fclose(fid);

fid = fopen(filename, 'a'); 
fwrite(fid, header);
while (count <= samples) 
    fwrite(fid, wave(count), 'float');
    fwrite(fid, ' ');
    count = count + 1;
end
fwrite(fid, 'CLOCK 1.10e+8');
fclose(fid);


fid = fopen(filename, 'at'); 
fprintf(fid, '\n');
fclose(fid);

Carl M
Tektronix Applications
Tektronix Applications
Posts: 796
Joined: July 30th, 2008, 4:45 pm
Country: United States

Re: Matlab - Save in WFM format

Post by Carl M » June 11th, 2014, 2:20 pm

assuming that ArbExpress, no-cost software provided AS-IS, is the "correct" *.wfm file format is... a dangerous assumption.

i define what is correct as what accomplishes your task. i'm glad you were able to find a solution and thank you for sharing.

azham
Posts: 7
Joined: May 30th, 2013, 12:58 am

Re: Matlab - Save in WFM format

Post by azham » June 11th, 2014, 8:42 pm

so the .wfm i got from the samples inside the ArbXpress is not a good comparison for a correct way to save .wfm?
Will it cause conflict if i run the file on a AWG?
I havent tested in on a physical AWG just checked with ArbXpress for verification.

Carl M
Tektronix Applications
Tektronix Applications
Posts: 796
Joined: July 30th, 2008, 4:45 pm
Country: United States

Re: Matlab - Save in WFM format

Post by Carl M » June 17th, 2014, 2:33 pm

AWG *.WFM files are used with the AWG400/500/600 (hundred) Series. The byte definitions are documented in the AWG400/500/600 Series Programmer Manual - Waveform File page 2-131 (161 of PDF) (http://www.tek.com/node/831025). awg5k/7k and the new awg70k support importing these old *.wfm to ease migration to new equipment but they have new formats as well.
Tektronix Application Engineer

Post Reply

Return to “Older and Obsolete Signal Sources”

Who is online

Users browsing this forum: No registered users and 4 guests