Reputation: 1316
I am trying to generate a score or a number which represents how many cos and sin waves can generate my signal. For example, if the signal is a sine wave this means it is 100% pure as it can be generated by only one sine signal, if it consists of two sine wave .. this means it is not pure wave and if it consists 100 sine waves it is really unpure and so on .... I tried FFT and FS but it didn't work ... Can anyone help me ??
Upvotes: 1
Views: 884
Reputation: 3616
Here you go:
x = s;
X = dct(x);
[XX,ind] = sort(abs(X),'descend');
i = 1;
while norm(X(ind(1:i)))/norm(X)<0.99
i = i + 1;
end
Needed = i;
Upvotes: 0
Reputation: 874
FFT will work. You must process wave with Fourier Transform, then calculate the magnitude sqrt(real*real + image*image). Counting the peaks of result will provide you number of sinewaves with different frequency.
Upvotes: 1