
Homepage

Signal Spectrum Homework Help Using Java
Signal Spectrum Java Function
Consider the function below. It produce the spectrum of a signal that can be treated as part of an infinite periodic signal.i.e. the sum of several harmonic signals, but not a single short pulse.
function [f, S] = get_spectr_simple(t, y)
if ( numel(t) != numel(y) )
print_usage ();
endif
tdiff = diff(t);
tol = 1e3;
if ( !all( abs(tdiff(1)tdiff(:))/mean(tdiff(:))) <= tol )
print_usage ();
endif
sample_rate = 1/abs(t(2)  t(1));
N = numel(t);
n = 2^(nextpow2(N));
%% Applying FFT to data
Y1 =fft(y, n); %using n elements makes algorithm faster
S1 = abs(Y1)/N; %It needs to be diveded by N to get the correct value.
f = sample_rate*(0:n/21)/n;
S = 2*S1(1:numel(f)); %The second part is symmetric for realvalued signals.
endfunction

Using this function try to process various signals and answer the following questions:
1. Find the error in function. Hint: add a constant component to the signal.
2. Why are the spectral amplitudes not exactly equal to the component amplitudes? How to improve the match?
3. Try to process the signals with different sampling periods and signals of different duration.
What changes in the obtained spectra can you mention? How can you explain the observed effects?
4. Try to put two frequencies close in the original signals (but not too close). What do you observe?
When the frequencies are resolved in the spectrum, and when are they not?
Also, try to variate the amplitudes (ratio of amplitudes) of these two close components (harmonics) along with their frequencies.
Which methods of handling such signals can you propose? Namely, how is it possible to resolve the close frequencies?
To resolve these tasks, try to implement several options:
a) Increase n (i.e. pad the original signal with zeros);
b) Considergga function from ltfat package;
c) Use window functions. Decide which one is the most suitable?