Maple
Home ] Up ] 54622D ] Audio ] Excel ] [ Maple ] MATLAB ] PSpice ]

 

Step 1: Create the waveform

Typically you create a waveform using symbolic commands. For example, the following Maple command produces a half cycle of a sinusoid with some of the front end chopped off:

v(t) := sin(t)*(Heaviside(t-1)); 

You can plot the waveform as follows:

plot(v(t), t=0..Pi);

Step 2: Create the .CSV file

The following code samples the function v(t) and save the samples to a .CSV file (see the Maple file linked below to save time entering this code). You need to specify the start time, end time, sampling interval, and the file name (the '>' character at the beginning of each line indicates the Maple prompt... do not enter it yourself):

> time_start := 0;
> time_stop := evalf(Pi);


> time_delta := evalf(Pi/100);


> file_name := "c:/temp/maple.csv"; #use forward slash, even in DOS/Windows


> fd := fopen(file_name, WRITE):


> for i from time_start by time_delta to time_stop do


    fprintf(fd, "%g\n",evalf(subs(t=i,v(t))));


> od:


> fclose(fd):

Example files

maple_csv.mws (Maple file)
maple_csv.csv (Data after conversion to .CSV format)

 

 

 

Department of Electrical and Computer Engineering
Rose-Hulman Institute of Technology
Terre Haute, IN 47803-3999

Page last updated 06/08/01