Sectioning Data for a frequency range

6 visualizaciones (últimos 30 días)
James Parkus
James Parkus el 4 de En. de 2018
Hi,
I am trying to take a large data matrix and section it into structures using a specific formula to specify the window indices. This is very difficult to explain.
I have a frequency range from 5 to 1800 Hz. The frequency increases logarithmically. I want to cut the data at a constant frequency step, say 50 Hz. The sampling rate of my DAQ is 10000. The test runs for 129.6 seconds. Thus I have 1296000 data points. The first window will contain the largest amount of data points. Then the number of data points in the frequency step will decrease.
I want to find the index in the frequency matrix (which contains each frequency point per second) that corresponds to a specific frequency. Ex: f = 100 Hz, find the index of the frequency matrix that contains the number closest to 100 Hz (the number is not an integer so we need to use logic to find the closest one).
Since I do not know how to directly call an index I created a for loop to search through every single line while keeping track of the iterations so it can be used as an index.
I am able to specify the begin and end points of the sectioning. Ex: Lower Bound = 1, Upper Bound = a, and then the next window is Lower Bound = Upper Bound + 1, Upper Bound = b, and this continues until I section the whole dataset.
The problem I have encountered with my code is that it repeats a line twice and stores the upper bound incorrectly. Here is an example.
798557-->886329; 886330-->886330; 886331-->948605; 948606-->948606; 948607-->996911
As you can see, it goes through every other line without advancing. It should look like this,
798557-->886329, 886330-->948605, 948606-->996910,...
Here is my code. You can ignore the Range_AVG stuff, that is working correctly. I find the best line to take by comparing the line above it and below it.
step = 50; % Step in frequency window
lim = 1800/step;
x = 1;
o = 1;
for u = 0:step:1800
for j = 2:1:1296000
if u >= f(j-1) && u <= f(j+1)
up(x) = j;
if x > 1
low(x) = up(x-1) + 1;
else
low(x) = 1;
end
x = x + 1;
end
end
Range_AVG.(sprintf('Win%d', o)) = (step/2) + u;
o = o + 1;
end
In case you need the frequency data, use the script below to generate it. Sorry the file is too big to attach here.
%%Constants
f(1) = 5; % Hz
s = 4/60; % Sweep Rate - octaves/seconds
%%Array Creation
for i = 2:1:1296000
f(i) = f(i-1)*2^(s*(T(i)-T(i-1)));
end
Any help would be greatly appreciated. Best, James Parkus

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by