I've tried to do a fast fourier transform in Matlab of some data taken from an experiment in the windtunnel trying to show the frequency of the velocity variation in a flow, but somehow I keep on getting 0Hz as the main frequency. Anyone has encountered this problem before and knows how to solve it or can explain me a bit better how to do the frequency transform.
Ps: It seems to be doing the fast fourier transform alright, the problem might be when converting the data from imaginary to real values
Help me please!
Thank you!
This is a pretty normal thing to encounter. The 0 Hz component (often referred to as the DC component in analogy to the electrical equivalent) is the constant, non-time-varying component of the data -- it's equivalent to the mean of the data. If you have data that does not have a mean of zero, this is a very normal thing to see.
If you want to, you can calculate the mean and then subtract it from your data series, but this is not really necessary, since it will only change that DC component of the FFT. If you're not interested in the DC component for your purposes, you can simply ignore it.
Related
I have some voltage data recorded from brain electrophysiology that look like this:
Raw voltage trace
Notice that the fluctuations <200 uV is the actual data and the huge peaks are artifacts that might arise from occasional touching of the reference with something else. I'm not an expert in electrical engineering, but the artifact looks like the step response of a high-pass filter that is used to remove the DC offset.
Now I'm trying to remove the artifacts by curve fitting. If I detect peaks in my diff(data) and avarage all waveforms around the peak, it looks like this:
Average artifact waveform
My questions are the following:
What is the function/kernal for the artifact? I thought exponential decay would work, but the waveform clearly has overshoot that an exponential decay doesn't. Is this actually a step response of a high-pass filter? If so, what's the analytical form?
How do I solve the fitting problem of expressing my signal as a sum of time-shifted and scaled kernals? cfit doesn't seem to be the correct option.
Thank you!
You can try using a superposition of three sigmoid functions, for example:
Yields this:
When used with parameters described in this Desmos: https://www.desmos.com/calculator/ouuauyihdt
You can probably simplify the equation a bit or add additional parameters, and then use any of the standard curve fitters to fit your data.
I have data on the position of the drone from a tracker, as well as estimates of velocity and acceleration based on that data from a Kalman filter variant that seem reasonably good.
I am looking to predict (/give a reasonable guess of) the position of the drone multiple seconds in the future, and I am uncertain if the best tactic is to keep estimating jerk, snap, crackle & pop and include them in the computation, or if there is a better method that I am missing.
Any help appreciated.
If you have estimated velocity and position, then pass it to your kalman filter. Then pass the output of kalman filter back to it and in this way loop it over again and again. See what happens. I used this method for 2D prediction and my predicted path improved with increasing number of datasets. Also you may need to tweak your control matrix.
I don't know how to compute the envelope of a signal. I've already seen the mathwork solutions firstSolution secondSolution but they does not work in the signal I'm working with.
This signal provides from a pressure sensor and it's sampled at a frequency of 1kHz and it has 100000 samples.
I've read that with the hilbert transform I could get the envelope by doing abs(hilbert(data)) being data the values of the signal2.txt but it has not work. I've also tried with taking the absolute value of the analytic signal but it has not work either.
The solution I've tried is to find the peaks and put them together linearly but it does not work properly because I want a continuous and derivable function as result so as I need to derivate it.
I hope you knew the solution to my problem. :)
I want to know the frequency of data. I had a little bit idea that it can be done using FFT, but I am not sure how to do it. Once I passed the entire data to FFT, then it is giving me 2 peaks, but how can I get the frequency?
Thanks a lot in advance.
Have a look at this page for an explanation on how to calculate it:
FFT Fundamentals
Please also check this answer (it's C# code but I think you can easily understand it)
How do I obtain the frequencies of each value in an FFT?
And finally have a look at this one, it uses DFT instead of FFT:
Determining the magnitude of a certain frequency on the iPhone
I also found this implementation that you can use in Objective-C:
A lib to find the frequency https://github.com/jkells/sc_listener
A example using the above library https://github.com/jkells/sc_listener_sample
Regards
An FFT will give you the frequency of all the sinusoidal components of a signal. If instead you want just the frequency of the periodicity of common waveforms (more interesting sounding and looking that a plain sinewave) such as produced by speech and music, then you may want to use a pitch detection/estimation algorithm instead of just an FFT peak.
I would like be able to use a vector as an envelope to apply fft equalization to rather large chunks of sound, with varying sizes.
To be able to multiply the frequency domain bins by the envelope, the envelope needs to have the same resolution as the fft data, which will vary with the size of the sound chunks.
So, I need a function to resample my envelope vector. Do you know whether vDSP features a function for that purpose? I browsed the reference back and forth, but found nothing. Which doesn't mean there is nothing there - it's easy to miss something while searching the vDSP reference...
It's not that I couldn't implement something myself, but if there was a vDSP function, it would propably be much faster than anything I could possibly come up with. Which is relevant as this project is targeted at iOS devices as well.
And there's no need to reinvent the wheel :)
Thanks!!
If I understand correctly, you have a 1D array of envelope values which you want to vector multiply with a 1D array of frequency bins. The problem you are trying to solve is to scale the envelope array to the same length as the FFT array. It would be helpful to know how you are generating the envelope array in the first place, can you not simply generate it at the correct length? If so, problem solved :)
If not, then how about using vDSP_vtabi to generate the envelope vector from the lookup table of values that you currently have? You can generate the lookup table input vector A using vDSP_vramp.
This seems rather complicated and expensive to me though, with a fair amount of buffer mallocing / reallocing. It might be simpler to calculate how many FFT samples should be multiplied by each envelope value, then loop for each envelope sample using vDSP_vsmul to multiply chunks of the FFT vector by the envelope value.
Which solution will perform better really depends a lot on the relative sizes of each vector. It would also be helpful to know why the FFT vectors are different sizes, and how you are generating the envelope array in the first place to give a more accurate answer.
I'd suggest to go through a different way.
Because your input signal comes from hardware at a fixed sample rate and you exactly
know the number of envelope values , just make a sample rate conversion using
AudioConverterFillComplexBuffer
It's fast and it take care about filtering and interpolation when resampling.