I don't use Scilab [I think that was its name] after a giant battle
with them over accuracy. They essentially told me tough.
After floundering for a few years, I discovered octave and have NOT
changed again. I do EXTENSIVE DSP work and octave not only predicted,
but taught me, a great deal about what was going on. During DSP
development after trying a process of manipulation in octave, it was a
piece of cake to write C/C++ real-time code to do the same thing. As
you know, battling code errors is enough to take on, not trying to
design the DSP processing at the same time.
Either you have to make certain you have a complete set of cycles for
each waveform in your FFT window, else you 'scatter' the energy of non
matching sinusoid into adjacent segments. Like 30% in one and 70% in
the next one, which makes your display look ghastly - but it is
correct by mathematical definitions. So...if you make the FFT window
of time match ALL waves THEN you'll get your expected results. If
impossible to match, you can use a window. Think of the window as
gently sliding into the data and then gently sliding back out, so the
'accidental' abrupt start and stop of your window over the waveforms
just doesn't happen. There are two very effective windows to use. go
to TI's ap note on their incredible ADS1282 24 bit data acquisition
system. They use a window that is a great compromise between
preserving energy and injecting noise into adjacent segments. In the
interim, I simply use an 'adjusted' hanning window which is fairly
easy and doesn't 'splatter' the energy around. Note, I said Hanning,
not Hamming. The shape of the hanning window is one cycle of a cos
wave, starts at zero goes to amplitude of 2, then returns to zero and
is EXACTLY the length of your FFT window. Octave provides that as a
supplied function so it's easy to use, but you can construct one
mathematically for your needs. Just keep in mind that whatever window
you use you MUST make the area under that window equal to one, else
you'll shift the amplitudes of your FFT, losing quantified answers,
only getting qualified answers.
Be FAR easier to talk in octave, rather than Scilab.