frequency

How to properly scale frequency axis in Fast Fourier Transform?

两盒软妹~` 提交于 2020-01-13 15:53:08
问题 I am trying some sample code taking the FFT of a simple sinusoidal function. Below is the code import numpy as np from matplotlib import pyplot as plt N = 1024 limit = 10 x = np.linspace(-limit, limit, N) dx = x[1] - x[0] y = np.sin(2 * np.pi * 5 * x) + np.sin(2 * np.pi * x) Y = np.abs(np.fft.fft(y) ** 2) z = fft.fftshift(np.fft.fftfreq(N, dx)) plt.plot(z[int(N/2):], Y[int(N/2):]) plt.show() From the function that is given, , it is clear there should be two spikes at frequencies 1 and 5.

Unable to get correct frequency value on iphone

元气小坏坏 提交于 2020-01-13 07:15:48
问题 I'm trying to analyze frequency detection algorithms on iOS platform. So I found several implementations using FFT and CoreAudio (example 1 and example 2). But in both cases there is some imprecision in frequency exists: (1) For A4 (440Hz) shows 441.430664 Hz. (1) For C6 (1046.5 Hz) shows 1518.09082 Hz. (2) For A4 (440Hz) shows 440.72 Hz. (2) For C6 (1046.5 Hz) shows 1042.396606 Hz. Why this happens and how to avoid this problem and detect frequency in more accurate way? 回答1: Resolution in

Mysql count frequency

穿精又带淫゛_ 提交于 2020-01-11 09:04:51
问题 I've checked similar questions but it didnt help in my precise question. So, my table goes like this: id age 1 30 2 36 3 30 4 52 5 52 6 30 7 36 etc.. I need to count the frequency of ages: age freq 30 2 36 3 52 2 How can I grab this freq? After this I will need to work with that data, so it might be necessary using array? Thanks! function drawChart() { // Create the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'age'); data.addColumn('number', 'freq');

C# Why are timer frequencies extremely off?

跟風遠走 提交于 2020-01-09 13:08:50
问题 Both System.Timers.Timer and System.Threading.Timer fire at intervals that are considerable different from the requested ones. For example: new System.Timers.Timer(1000d / 20); yields a timer that fires 16 times per second, not 20. To be sure that there are no side-effects from too long event handlers, I wrote this little test program: int[] frequencies = { 5, 10, 15, 20, 30, 50, 75, 100, 200, 500 }; // Test System.Timers.Timer foreach (int frequency in frequencies) { int count = 0; //

C# Why are timer frequencies extremely off?

大兔子大兔子 提交于 2020-01-09 13:07:47
问题 Both System.Timers.Timer and System.Threading.Timer fire at intervals that are considerable different from the requested ones. For example: new System.Timers.Timer(1000d / 20); yields a timer that fires 16 times per second, not 20. To be sure that there are no side-effects from too long event handlers, I wrote this little test program: int[] frequencies = { 5, 10, 15, 20, 30, 50, 75, 100, 200, 500 }; // Test System.Timers.Timer foreach (int frequency in frequencies) { int count = 0; //

C# Why are timer frequencies extremely off?

白昼怎懂夜的黑 提交于 2020-01-09 13:07:42
问题 Both System.Timers.Timer and System.Threading.Timer fire at intervals that are considerable different from the requested ones. For example: new System.Timers.Timer(1000d / 20); yields a timer that fires 16 times per second, not 20. To be sure that there are no side-effects from too long event handlers, I wrote this little test program: int[] frequencies = { 5, 10, 15, 20, 30, 50, 75, 100, 200, 500 }; // Test System.Timers.Timer foreach (int frequency in frequencies) { int count = 0; //

《DSP using MATLAB》Problem 9.2

[亡魂溺海] 提交于 2020-01-09 08:16:24
前几天看了看博客,从16年底到现在,3年了,终于看书到第9章了。都怪自己愚钝不堪,唯有吃苦努力,一点一点一页一页慢慢啃了。 代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 9.2 \n\n'); banner(); %% ------------------------------------------------------------------------ % ------------------------------------------------------------ % PART 1 % ------------------------------------------------------------ % Discrete time signal n1_start = 0; n1_end = 60; n1 = [n1_start:1:n1_end]; xn1

How to build frequency matrix in R?

风流意气都作罢 提交于 2020-01-07 16:16:11
问题 Suppose that the existing data frame named as A contains the following data: Time Var T1 loc1 T1 loc2 T1 loc3 T2 loc2 T2 loc2 T2 loc3 T3 loc1 T3 loc3 T3 loc3 I want the output frequency matrix in R in the following format loc1 loc2 loc3 T1 1 1 1 T2 0 2 1 T3 1 0 2 I tried using apply() , table() but could not understand how to use them to get my required output. Can somebody suggest me some functions in R which I can use to get the required output? 回答1: You could go for xtabs in base R xtabs(

How to build frequency matrix in R?

谁都会走 提交于 2020-01-07 16:15:11
问题 Suppose that the existing data frame named as A contains the following data: Time Var T1 loc1 T1 loc2 T1 loc3 T2 loc2 T2 loc2 T2 loc3 T3 loc1 T3 loc3 T3 loc3 I want the output frequency matrix in R in the following format loc1 loc2 loc3 T1 1 1 1 T2 0 2 1 T3 1 0 2 I tried using apply() , table() but could not understand how to use them to get my required output. Can somebody suggest me some functions in R which I can use to get the required output? 回答1: You could go for xtabs in base R xtabs(

Creating a Letter a Histogram

青春壹個敷衍的年華 提交于 2020-01-07 09:48:09
问题 So I want to create a histogram. Here is my code: def histogram(s): d = dict() for c in s: if c not in d: d[c] = 1 else: d[c] += 1 return d def print_hist(h): for c in h: print c, h[c] It give me this: >>> h = histogram('parrot') >>> print_hist(h) a 1 p 1 r 2 t 1 o 1 But I want this: a: 1 o: 1 p: 1 r: 2 t: 1 So how can I get my histogram in alphabetical order, be case sensitive (so "a" and "A" are the same), and list the whole alphabet (so letters that are not in the string just get a zero)?