 You have no items in your shopping cart.

×

### Registration

Profile Informations

# IDSG101 Manual: How to Transform the Arbitrary Waveform Format (PART 2)

MATLAB is a programming language developed by MathWorks. It started out as a matrix programming language where linear algebra programming was simple. It can be run both under interactive sessions and as a batch job. Alternatives to MATLAB exist including open source software packages. —From wikibooks.org

IDSG101 Arbitrary Waveform Generator supports wvt file output only. You can use Matlab to generate a wvt arbitrary waveform file.

Matlab User Guide: http://www.mathworks.com/help/pdf_doc/matlab/getstart.pdf?s_tid=int_tut

### File Converting Function

We’ve made an arbitrary waveform format converting file here, the source code as below:

``````	%=======================================
% Program to generate wvt file for IDSG101
%=======================================

function arb(x,fre,amp,offs)
% clean workbench
close all
clc
% set up file
fid=fopen('arb0.wvt','wt') ;
fprintf(fid,';==== arb file generator for gk101 ====\n');
% write frequency
fprintf(fid,'[frequency] = %f;\n',fre);
% write amplitude
fprintf(fid,'[amplitude] = %f;\n',amp);
% write offset
fprintf(fid,'[offset] = %f;\n',offs);
% write date
fprintf(fid,'[date] = %d-%d-%d;\n',year(now),month(now),day(now));
% extract data range
fprintf(fid,'[datarange] = %f,%f;\n',min(x),max(x));
[m,n]=size(x);
% extract length and write
fprintf(fid,'[length] = %d;\n',n);
% write data
fprintf(fid,'[data] = \n');
fprintf(fid,'%f,%f,%f,%f,%f,\n',x);     % output matrix
% close file
fclose(fid)
``````

It is a very simple program. Anyone who didn’t use Matlab before could understand its sketch. Download the program here, you’d better extract it in Matlab root directory in any hard disk.

### Steps

In this article, we will generate a sine waveform that overlay white noise. Let’s make it.

1. Enter into the directory where arb.m is located using cd command. As we put arb.m file in Matlab directory in D disk, the command is cd d:\matlab 2. Generate a sine waveform through commands

In the picture below, the formula x = 0:0.01:2*pi means generating a matrix x that contains data from 0 to 2π and with time interval 0.01

y = sin(x) calculate the sine signals, and save them to matrix y. 3. Overlay white noise

In the below picture, z = awgn(y,20) represents overlaying SNR 20dB white noise, and the data save in matrix z. ``````    subplot(2,1,1);
plot(y)
subplot(2,1,2);
plot(z)
``````

These four sentences above are for creating the waveform. You can see the original waveform and the last waveform that overlaid with white noise in the following picture. 4. Invoke function and save the file

In arb(z,1000,5,0), the different parameters have different meaning: z means the matrix data needed to be save; 1000 means waveform frequency, 5 means waveform amplitude, 0 means DC-offset.

Run the command, the arbitrary waveform file arb0.wvt will be generated. 5. Put arb0.wvt in IDSG101, connect the device to oscilloscope, we can out put the waveform we make. 