Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Spectral Analysis and SALP tollbox

Status
Not open for further replies.

seifer

Newbie level 4
Newbie level 4
Joined
Jun 14, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
sg_cissoid

now anything about SALP TOOLBOX?
this is the code of the signal :
[y, t] = sg_cissoid(beta, f, Dim, <OSF>, <SNR>)
%
% Parameters: - beta : Vector with complex amplitudes
% - f : Vector with frequency values (-0.5 < f < 0.5)
% - Dim : Number of samples
% - OSF : Oversampling factor (default: OSF = 1)
% - SNR : Signal to Noise ratio in [dB] (default: SNR = inf)
%
% Output: - y : Vector with signal samples
% - t : Time axis
and this is the code of welch for example :

[PSD, f] = psd_welch(y, <Win>, <N_Overlap>, <N_FFT>, <fs>)
%
% Parameters: - y : Vector with signal samples
% - Win : The signal is divided into K_seg overlapping
% segments of length equal to the length of
% the window and windows each segment
% (default: 8 segments with Hamming window)
% - N_Overlap : Number of overlapping samples from segment to
% segment (default: 50% overlap)
% - N_FFT : Number of FFT points (default: N_FFT = 256)
% - fs : Sampling frequency in Hz (default: fs = 1 Hz)
%
% Output: - PSD : Power spectral density
% - f : Frequency axis
anyone can tell me...which parameters should i change to see the resolution ???
 

In order to examine how the resolution changes you have to change the parameters of the signal being analyzed, i.e. the tone frequencies, their amplitudes and SNR in sg_cissoid function. By changing these parameters you can find the minimum difference in frequencies that allows to see harmonics in the output spectrum estimate (PSD plot) as the two distinct lines. In real application you will have to supply the resolution threshold for the PSD analysis - the probability of correct resolution is strongly dependent on the threshold. When working with parametric estimation methods it possible examine the complex roots of PSD spectrum estimate instead of the PSD plot itself.
 

thank you very much for your responce first...i would like to know another thing...i need to see this in 64 data values then 128 etc...so i think i need a loop for parameter f right ?...and i need a loop that gives the appropriate random numbers...can u tell me how i ll do that ?...and if this is the correct thing to do
 

Actually, I never worked with SALP Toolbox, but I made the similar things with Signal Processing Toolbox. I guess that You will need three loops:
the first one is for the dataset length (Dim in the definition of the sg_cissoid function),
the second one is for the difference between tone frequencies (if you want to examine how the results change at different tones displacement ) - it is the difference of the two values (assuming 2-tone signal) in vector f,
and the third one is for the SNR (if you want to examine the noise level influence as well).
I didn't understand what you meant by random numbers. If You meant noise than I guess that sg_cissoid function uses a fuction like wgn from Signal Processing Toolbox, so you don't have to bother about generating noise manually. You will only have to supply the sg_cissoid function with an appropriate value of the SNR parameter.
 

One more time thx a lot for your responce...i could use too the signal proccesing toolbox...but it has very few functions for psd...can u tell how can i find more for this ?i mean that for example the first time i ll examine psd for 64 data values...after that for 128 and then observe the resolution...so i ll need 64 different f for my code...right ?and if i m right...how i ll do that loop ?

Added after 3 minutes:

and one more thing...this is the c code for the given cissoid function
function varargout = sg_cissoid(beta, f, Dim, varargin);

% Check parameters
error(nargchk(3,5,nargin));
[msg, OSF, SNR] = chk_param(beta, f, Dim, varargin{:});
error(msg);

% Sampling parameters
fmax =0.5;
fn = 2 * fmax;
T = 1 / (OSF * fn);

% Setup axis
t = T * [0:Dim-1];

% Preprocess data
beta = beta:)).';
f = f:));

% Generate signal
x = beta * exp(j*2*pi * f * t);

% Add noise if necessary
if(SNR ~= inf)
y = add_noise(x, SNR);
else
y = x;
end

% Display results if no output argument is defined
if(nargout == 0)
figure('name','Signal Generator: Superimposed cissoids in white noise','NumberTitle','off');
subplot(2,2,1);
plot(t, abs(y));
xlabel('Time t ');
ylabel('Magnitude - absolute value');
subplot(2,2,2);
plot(t, angle(y));
xlabel('Time t ');
ylabel('Magnitude - phase');
subplot(2,2,3);
plot(t, real(y));
xlabel('Time t ');
ylabel('Magnitude - real part');
subplot(2,2,4);
plot(t, imag(y));
xlabel('Time t ');
ylabel('Magnitude - imaginary part');
else
% Assign output arguments
varargout{1} = y.';
varargout{2} = t.';
end

return;


% check parameters and setup defaults if necessary
function [msg, OSF, SNR] = chk_param(beta, f, Dim, varargin);

% No error message
msg = '';

% Get optional parameters
if(nargin > 3 & ~isempty(varargin{1}))
OSF = varargin{1};
else
OSF = 1;
end
if(nargin > 4 & ~isempty(varargin{2}))
SNR = varargin{2};
else
SNR = inf;
end

% Check parameter
if(OSF < 1)
msg = 'Over-sampling factor ''OSF'' must be at least of value ''1''.';
return;
end
if(length(OSF) > 1)
msg = 'Parameter ''OSF'' must be a scalar.';
return;
end
if(length(SNR) > 1)
msg = 'Parameter ''SNR'' must be a scalar.';
return;
end
if(any(Dim <= 1) | length(Dim) ~= 1)
msg = 'No one-dimensional signal specified.';
return;
end
if((length(beta) ~= length(f)))
msg = 'Parameter vectors ''beta'' and ''f'' must be of same length.';
return;
end
fmax =0.5;
if(any(abs(f) > fmax))
msg = 'Don''t exceed Nyquist-frequency limit of |fmax| = 0.5 Hz.';
return;
end

return;
u told me that only f and dim affect the psd...but if i give a different OSF i observes differences in plot..can u tell me why ?
 

i could use too the signal proccesing toolbox...but it has very few functions for psd...can u tell how can i find more for this ?
There are enough PSD functions in the SP toolbox:
pburg - Burg's PSD estimation method
pcov - Covariance PSD estimation method
peig - Eigenvector PSD estimation method
periodogram - Periodogram PSD estimation method
pmcov - Modified Covariance PSD estimation method
pmtm - Thomson multitaper PSD estimation method
pmusic - Multiple Signal Classification PSD estimation method
pwelch - Welch's PSD estimation method
pyulear - Yule-Walker AR PSD estimation method
rooteig - Sinusoid frequency and power estimation via the eigenvector algorithm
rootmusic - Sinusoid frequency and power estimation via the MUSIC algorithm
spectrogram - Spectrogram using a Short-Time Fourier Transform (STFT)


i mean that for example the first time i ll examine psd for 64 data values...after that for 128 and then observe the resolution...so i ll need 64 different f for my code...right ?
You don't need to check all possible tone frequencies between -0.5 and +0.5, instead concentrate on small displacements which are close to 1/Dim.
I think that you need to do something like this:
beta=[b1,b2];
for k=6:10
Dim=2^k;
for m=1:10
dF=10-m;
f1=-dF/(2*Dim);
f2=dF/(2*Dim);
f=[f1,f2];
[y, t] = sg_cissoid(beta, f, Dim, 1, snr) ;
[PSD, F] = psd_welch(y, <Win>, <N_Overlap>, <N_FFT>, 1);
end
end

Keep in mind that the resolution capabilities of parametric methods like music and Burg can be better than you will be able to see with the PSD plots. And also, IMHO the PSD plot is not the best way to characterize resolution.

Contact me via PM if you have additional questions.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top