need help with this
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
dulanga
il 16 Apr 2019
Commentato: Walter Roberson
il 16 Apr 2019
turn all the amplitudes of frequencies which are higher than 3500 Hz into 0’s and amplify the rest of the spectrum (by just multiplying the spectrum by some large number so that the amplitudes are around 2000-3000 in magnitude
how do i do this ? like what would the code be like?
0 Commenti
Risposta accettata
Sajeer Modavan
il 16 Apr 2019
a = [10;15;3600;4500;45;67;100];
[ind,~] = find(a>=3500);
b = a;
b(ind) = 0;
c = b*30
16 Commenti
Walter Roberson
il 16 Apr 2019
discrete fourier transform theory says that you can take a function, f(x), and represent it as a sum of coefficients, each associated with a frequency -- essentially a sum of sine waves. The first slot of fft output is associated with "0 Hz", the DC constant. The second slot of fft output is for one cycle over the signal; the third slot is for two cycles over the signal; the third slot is for three cycles over the signal, and so on until you get to the middle slot, which for signal length L is associated with L/2 cycles per signal. The fact that you do not go on from there to (L/2+1), (L/2+2) and so on does have to do with Nyquist: Nyquist tells you that you cannot resolve anything more than L/2 cycles in a signal length L.
Once you get to the middle, then you start counting down again, possibly a repeat of L/2 (but not necessarily), and then L/2-1, L/2-2 and so on down to 1 (but not down to 0). When the input signal was entirely real-valued, then the coefficient in fft output array location K is the complex conjugate of the coefficient in location end-K+2. In the case of an input signal known to be entirely real-valued, you can reconstruct the entire signal from the first half of the fft() output, but it is easier to use the setup the way it is, as the current setup extends naturally to complex signals.
Now, when I say "one cycle over the signal, two cycles over the signal", and so on, I know that sounds like "Hz". But Hz is "cycles per second", and the signal is not necessarily one second long. If the signal were 2 seconds long, then "one cycle over the signal" would be 1 cycle in 2 seconds, which would be 1/2 Hz, for example. Two cycles over the signal would be 2 cycles in 2 seconds, 1 Hz. Three cycles over the signal would be 3 cycles in 2 seconds, 3/2 Hz. And so on. Notice that the adjacent slots are a constant frequency apart from each other. To know how many Hz each slot in the fft output represent, you need to do a small calculation. The calculation can be done if you know the total time that the signal represents, but it can also be done without that total time (directly) if you know the sampling frequency of the original signal, fs, which you get as the second output of audioread(). If you have more than one second of input, then the slots will correspond to frequencies less than fs apart; if you have less than one second of input, then the slots will correspond to frequencies more than fs apart.
For your task, you need to convert the bin numbers (cycles per signal) into absolute frequencies, because you are asked to filter based upon absolute frequencies. The Freqs calculation I posted earlier calculates the first half of that array, but does not continue on to count backwards down to lower frequencies again.
For mirroring: suppose you had an input vector x1 = [0 -1 2 -3 4] . Now, what expression would you write to get out [0 -1 2 -3 4 4 -3 2 -1] (case where original signal was odd length) ? What expression would you write to get out [0 -1 2 -3 4 -3 2 -1] (case where original signal was even length) ?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!