Any DSPers using Scilab [ NEWBIE in trouble ; ]

Started by Richard Owlett September 4, 2004
Anyone have Scilab 2.7 or 3.0 up and running under WinXP?

I'm trying to plot magnitude of FFT of rectangular pulse/window.

My code is

a(1:899)=1;
a(900:1000)=0;
plot2d( [1:1000], abs(fft(a,-1)), logflag="nl")

My output does not resemble what Mr. Lyons gives in Figure 3-25c.

Multiple sources agree with Rick ,)


Hi Richard, I've got scilab but I'm not a DSper and I haven't got Mr Lyons
book ( although I've read good things about it). All I can say is that the
output from scilab looks good to me : the first plotted point is the DC
offset then it moves through the positive frequencies in increasing
frequency , steps to the most negative frequency bin and plots those in
increasing prequency (i.e. thats the way the FFT output is organised).

Best of luck - Mike

"Richard Owlett" <rowlett@atlascomm.net> wrote in message
news:10jkl2umfkcu3f3@corp.supernews.com...
> Anyone have Scilab 2.7 or 3.0 up and running under WinXP? > > I'm trying to plot magnitude of FFT of rectangular pulse/window. > > My code is > > a(1:899)=1; > a(900:1000)=0; > plot2d( [1:1000], abs(fft(a,-1)), logflag="nl") > > My output does not resemble what Mr. Lyons gives in Figure 3-25c. > > Multiple sources agree with Rick ,) > >
As a guess - maybe you are trying to plot an approximate power spectral
density? If so using abs()^2  is better,

Mike

"Richard Owlett" <rowlett@atlascomm.net> wrote in message
news:10jkl2umfkcu3f3@corp.supernews.com...
> Anyone have Scilab 2.7 or 3.0 up and running under WinXP? > > I'm trying to plot magnitude of FFT of rectangular pulse/window. > > My code is > > a(1:899)=1; > a(900:1000)=0; > plot2d( [1:1000], abs(fft(a,-1)), logflag="nl") > > My output does not resemble what Mr. Lyons gives in Figure 3-25c. > > Multiple sources agree with Rick ,) > >
Richard Owlett wrote:
> Anyone have Scilab 2.7 or 3.0 up and running under WinXP? > > I'm trying to plot magnitude of FFT of rectangular pulse/window. > > My code is > > a(1:899)=1; > a(900:1000)=0; > plot2d( [1:1000], abs(fft(a,-1)), logflag="nl") > > My output does not resemble what Mr. Lyons gives in Figure 3-25c. > > Multiple sources agree with Rick ,) > >
It looks like exactly what you'd expect from the given code -- I don't have the book, so I can't comment on the figure. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Richard Owlett <rowlett@atlascomm.net> wrote in message
news:<10jkl2umfkcu3f3@corp.supernews.com>...
> Anyone have Scilab 2.7 or 3.0 up and running under WinXP? > > I'm trying to plot magnitude of FFT of rectangular pulse/window. > > My code is > > a(1:899)=1; > a(900:1000)=0; > plot2d( [1:1000], abs(fft(a,-1)), logflag="nl") > > My output does not resemble what Mr. Lyons gives in Figure 3-25c. > > Multiple sources agree with Rick ,)
The figure start indexing from -(M-1)/2, not 0. Matlab has some function called "fftshift" to 'swap' the higher and lower ends of the spectrum, so that the DC component appears in the middle of the plot and not in the first sample. Perhaps scilab has a similar function. Rune
Mike Yarwood wrote:
> As a guess - maybe you are trying to plot an approximate power spectral > density? If so using abs()^2 is better, > > Mike >
I was trying to reproduce his figures. It's part of a sequence he uses to explain DFT's of rectangular functions.
Rune Allnor wrote:

> Richard Owlett <rowlett@atlascomm.net> wrote in message
news:<10jkl2umfkcu3f3@corp.supernews.com>...
> >>Anyone have Scilab 2.7 or 3.0 up and running under WinXP? >> >>I'm trying to plot magnitude of FFT of rectangular pulse/window. >> >>My code is >> >>a(1:899)=1; >>a(900:1000)=0; >>plot2d( [1:1000], abs(fft(a,-1)), logflag="nl") >> >>My output does not resemble what Mr. Lyons gives in Figure 3-25c. >> >>Multiple sources agree with Rick ,) > > > The figure start indexing from -(M-1)/2, not 0. Matlab has some > function called "fftshift" to 'swap' the higher and lower ends > of the spectrum, so that the DC component appears in the middle > of the plot and not in the first sample. Perhaps scilab has a > similar function. > > Rune
That's not the problem. I'm used to making that swap mentally. I tried reducing number of points by a factor of 10. ie a(1:89)=1; a(90:100)=0; plot2d( [1:100], abs(fft(a,-1)), logflag="nl") That plot closely resembled Rick's. I went back and plotted the original 100 points at a time. The individual sections resembled Rick's. Question for all: Is there somewhere I can post my 100 point and 1000 point plots ( jpg files)?
Richard Owlett wrote:

   ...

> Question for all: > Is there somewhere I can post my 100 point and 1000 point plots ( jpg > files)?
Unless I missed something useful, alt.binaries seems to be entirely given over to porn. Not pictures, but lists of web sites. I suppose you can post there anyway, like old times. You can email them to me; I'll give them a URL of their own. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
Jerry Avins wrote:

> Richard Owlett wrote: > > ... > >> Question for all: >> Is there somewhere I can post my 100 point and 1000 point plots ( jpg >> files)? > > > Unless I missed something useful, alt.binaries seems to be entirely > given over to porn. Not pictures, but lists of web sites. I suppose you > can post there anyway, like old times. You can email them to me; I'll > give them a URL of their own. > > Jerry
Thanks, I've sent you copies. At least I think I have. I'm not getting incoming mail but outgoing apparently works.
Richard Owlett <rowlett@atlascomm.net> wrote in message
news:<10jkl2umfkcu3f3@corp.supernews.com>...
> Anyone have Scilab 2.7 or 3.0 up and running under WinXP? > > I'm trying to plot magnitude of FFT of rectangular pulse/window. > > My code is > > a(1:899)=1; > a(900:1000)=0; > plot2d( [1:1000], abs(fft(a,-1)), logflag="nl") > > My output does not resemble what Mr. Lyons gives in Figure 3-25c. > > Multiple sources agree with Rick ,)
Here's my attempt to plot the spectrum of a sinc pulse. Code in matlabese, as always: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% N=64; % Length of frame M=16; % Length of rectangular pulse s=zeros(N,1); % Allocate initial memory for signal s(1:M)=ones(M,1); % Set non-zero samples plot(fftshift(abs(fft(s)))) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Rune