Fourier transform (fft) in MATLAB from accelerometer data for acceleration, velocity and position

  Рет қаралды 19,000

Mathias Magdowski

Mathias Magdowski

Күн бұрын

In this short video, I explain how to import a given txt file with raw data from some accelerometer in MATLAB, how to extract time steps (in the unit s) and the linear acceleration (in the unit m/s²) into a certain direction from the given matrix, and how to plot this time domain data. The velocity (in the unit m/s) and the position (in the unit m) can be calculated from the acceleration by numerical integration using the 'cumtrapz' function from MATLAB. After checking the validity (setting the first time step to zero, and making sure that all time steps are equidistant) and detrending the data (using the 'detrend' function from MATLAB), I show how to calculate the frequency spectrum and the corresponding frequency values using the given 'fourier' function, and how to plot the amplitude spectrum with a logarithmic axes scaling. Finally, I show how to calculate the maximum change of position at a certain frequency from the maximum change of accelaration and velocity directly, and to compare the results with the initial calculation.
MATLAB source code of the example:
cloud.ovgu.de/s/iN85Gqs8MJx7dQm
Chapter marks:
0:00 Introduction
0:21 Load the data set
0:53 Plot the time function
2:54 Calculate the velocity and position
5:51 Look at the time function
7:18 Window and detrend the data
11:16 Check for equidistant time steps and set the first time step to zero
12:28 Fourier transform of the position
13:24 Plot and look at the spectrum of the position
16:08 Find the maximum amplitude and corresponding frequency
19:10 Intermediate summary
19:40 Alternative solution from the spectrum of the acceleration
20:32 Plot and look at the spectrum of the acceleration
21:31 Calculate the velocity and position
26:15 Compare the results
26:37 Fourier transform of the velocity
27:58 Summary and discussion
28:55 Final advice

Пікірлер: 77
@ZachariaszKrawczyk
@ZachariaszKrawczyk Жыл бұрын
Fantastic video thanks a lot for your help
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
You are welcome.
@the_bumm
@the_bumm 9 ай бұрын
Impressive video! I’m currently conducting research to explore the relationship between various sizes of compressed air leaks and their corresponding frequency shifts, employing accelerometers for measurement. One notable challenge I’m encountering involves effectively analyzing the FFT spikes amidst the accompanying noise. I’d greatly appreciate your insights on the most effective techniques to mitigate noise in the final FFT results. I am having a difficult time improving the plots with windows and or signal averaging.
@MathiasMagdowski
@MathiasMagdowski 9 ай бұрын
Noise is a broadband process. Your useful signals are rather narrowband. One of the things to try is to filter your signal for the interesting frequency components and to suppress the unwanted frequencies components including the noise using transfer functions of high-pass, low-pass, band-pass or band-stop filters. You can also try the average your calculated spectra over a certain amount of time as noise will typically cancel out. Nevertheless, if the transient signal in time domain only consists of noise, then the spectrum will also more or less only show noise.
@guenthermeinname7000
@guenthermeinname7000 Жыл бұрын
Hi Mathias, danke für das Video! Ich untersuche zur Zeit Beschleunigungsdaten von einem Masse-Feder Ersatzmodell, welches durch einen Hammerschlag erregt wird. Ich bin vor allem interessiert am Frequenzspektrum. Wenn ich das z.B über FFT oder pwelch plotte (auch mit vorheriger Filterung und Offset-Bereinigung) habe ich einen 0Hz peak und sozusagen ein "Roll-Off" Verhalten von 0Hz aufwärts. Also ein bisschen wie in dem Video das Spektrum des Displacements. Haben sie da eine Idee, woran das noch liegen könnte? Vielen Dank!
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
Vielen Dank für die Frage und Entschuldigung für die etwas verzögerte Rückmeldung, aber ich war im Urlaub und auf Dienstreise. Ohne die konkrete Zeitfunktion zu sehen, sind solche Ferndiagnosen immer etwas schwierig. Ich vermute jedoch, dass es dort eine gewisse langsame Drift gibt, die dann bei tiefen Frequenzen entsprechende Anteile im Spektrum hervorruft. Möglicherweise endet die Zeitfunktion auch nicht mit demselben Amplitudenwert, mit dem sie beginnt. Der FFT-Algorithmus geht davon aus, dass die Zeitfunktion zyklisch fortgesetzt wird und sich immer weiter wiederholt, so dass eine quasi-periodische Funktion entsteht. Wenn der Anfangs- und der Endwert nicht gleich sind, gibt es einen großen Sprung oder eine große Stufe, die viele Artefakte im Spektrum erzeugt, die eigentlich nicht vorhanden sind, sondern nur aufgrund dieses Sprungs auftreten. In einem solchen Fall kann es hilfreich sein, die Zeitfunktion und den Anfang oder das Ende abzuschneiden, um die Anfangs- und Endamplitude anzugleichen, oder eine Fensterfunktion zu verwenden (siehe de.wikipedia.org/wiki/Fensterfunktion).
@guenthermeinname7000
@guenthermeinname7000 Жыл бұрын
Danke für die Antwort @@MathiasMagdowski! Mit Fenstern habe ich bereits viel ausprobiert/gearbeitet, das führt allerdings nicht wirklich zu zufriedenstellenden Ergebnissen. Angenommen das Signal ist von langsamen Drifts beeinflusst, wie kann man das untersuchen und unter Umständen "bekämpfen"?
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
@@guenthermeinname7000 Einen langsamen Drift oder Trend erkennt man daran, dass sich der Funktionswert neben der Schwingung, die ja eigentlich von Interesse ist, langsam nach "oben oder unten" wegbewegt und eben wegdriftet, so wie hier zu sehen: kzfaq.info/get/bejne/i5ahlqeqspzJZqs.html Ursachen für solche Drifts sind Messfehler, z.B. durch Temperaturänderungen oder Ähnliches. Mit Hilfe der ebenso im Video beschriebenen detrend-Funktion in MATLAB kann man solche Trends aus den Daten herausfiltern.
@Luigi_re2000
@Luigi_re2000 Жыл бұрын
I have velocity data measure s in the laboratory ( in all direction ) and I want to do the turbulence spectrum graph to see the curve of -5/3”2D spatial Fourier” , but I don’t know how to process the information. Any suggestions?
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
Dear Luigi, thanks for your inquiry. Can you give some more details about the '-5/3 2D spatial Fourier' decomposition? If you want to do a two-dimensional Fourier analysis, you may use the fft2 function from MATLAB instead of the plain fft function for the one-dimensional analysis, see: www.mathworks.com/help/matlab/ref/fft2.html
@user-to9jk5hm3i
@user-to9jk5hm3i 7 ай бұрын
You are doing great work ❤, Can you make a video for retrieving the mode shape of the beam using contact point response?
@MathiasMagdowski
@MathiasMagdowski 7 ай бұрын
What do you exactly mean by that? Which beam is meant and what is described by its mode shape? What responds to the point contact and how? How is this contact established?
@user-to9jk5hm3i
@user-to9jk5hm3i 7 ай бұрын
@@MathiasMagdowski if we have acceleration response data of beam then how can I plot the mode shape of beam.
@MathiasMagdowski
@MathiasMagdowski 7 ай бұрын
@@user-to9jk5hm3i You mean a cantilever beam where one end is fixed, right? For how many points along the deflected cantilever beam do you have acceleration data?
@user-to9jk5hm3i
@user-to9jk5hm3i 7 ай бұрын
@@MathiasMagdowski no for simple supported beam.
@MathiasMagdowski
@MathiasMagdowski 7 ай бұрын
​@@user-to9jk5hm3i You mean a simply supported beam, having two supports at either end - one pinned and one roller? Still, for how many points along the deflected simply supported beam do you have acceleration data? How is the beam excited or how is the vibration generated?
@onedepressedengineer_2003
@onedepressedengineer_2003 6 ай бұрын
Great Video sir. Although I have a slight inherent difficulty. I have a data of more than 2900 readings of wind speeds, each taken at a minute (so basically I have more than 2900 minutes of speed data) but the problem is that they are not in harmonic nature. Is it possible to convert random data into harmonic? My end goal is to apply the FFT on the speed vs time data in order to express it into speed vs frequency data so that I can pluck out the dominating frequencies that give out a certain magnitude of speed.
@MathiasMagdowski
@MathiasMagdowski 6 ай бұрын
Thanks for your question. I suggest to plot your time function and thoroughly look at it, zoom in and zoom out. If you observe that it mainly shows noise and random or stochastic fluctuations only, then there is probably no regular or periodic pattern present and no harmonic oscillations occured. Therefore, if you calculate the spectrum of the signal, it will probably also only show noise and no specific resonant frequencies. Another thing: When applying the FFT, the longest time in the time range corresponds the the smallest frequency and vice versa, the smallest time corresponds to the highest frequency. So with a total time range of 2900 min = 174 000 s, the smallest frequency in your spectrum will be approximately 5.74 µHz. As your time step is 1 min = 60 s, the highest frequency in the spectrum will be approximately 16.6 mHz. The question is, if this is your frequency range of interest or not. If you are interested in even lower frequencies, you need to sample longer in time domain. If you are interested in higher frequencies, you need to sample faster in time domain.
@nathanaelwailyn8490
@nathanaelwailyn8490 6 ай бұрын
Hi Mathias, I have a vibration data taken from an accelerometer on a cnc machine , I have the acceleration-time data but when converting it to displacement, I get a smooth graph , when zooming in, there is no oscillation like the one you have obtained from this video, hence, I am unable to obtain an accurate frequency graph. Any suggestion?
@MathiasMagdowski
@MathiasMagdowski 6 ай бұрын
Thanks for the question. How did you convert the acceleration (im m/s²) into a displacement (in m), directly in time domain using the cumtrapz and detrend functions or in frequency domain by dividing the obtained spectrum of the acceleration two times by j·ω (where j is the imaginary unit and ω is the angular frequency in 1/s) and then using and inverse Fourier transform back into time domain? Have you tried to use my code example linked in the video description? I suggest to monitor and display the result of each intermediate step of the calculation in order to check the correctness of the approach and the validity of the outcomes.
@faridpiran8140
@faridpiran8140 Жыл бұрын
Hi Mathias, from experiment of the cantilever beam, I obtained the time and millivolt from accelerometer, now I want to plot real and imaginary part of FFT in MATLAB code by using Nyquist. Could you please help me. Thanks
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
You may send me your data and corresponding MATLAB files to my e-mail address mathias.magdowski@ovgu.de. If you do so, please: - don't forget to attach the (preferably zipped) code to the mail - clearly indicate the main program or script to run - make sure (if possible) that it runs on your computer without problems/errors - meaningfully comment every single line of code - describe what the program should do, what to expect as the output and any discrepancy from that - don't send me files, which are not necessary - have questions as specific as possible
@user-to9jk5hm3i
@user-to9jk5hm3i 7 ай бұрын
Great work, You are helping us. Can you provide your codes also?
@MathiasMagdowski
@MathiasMagdowski 7 ай бұрын
Thanks for your inquiry. The MATLAB source code of the example is linked in the video description: cloud.ovgu.de/s/iN85Gqs8MJx7dQm
@mohamedredaboulezaz6498
@mohamedredaboulezaz6498 Жыл бұрын
hello sir, i have vibration data and i want to plot the fft of the velocity and acceleration, however the fft i get doesnt represent the expected plot and the frequency components are not peaking in the correspending rpm! can you please help
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
You may send me your data and corresponding MATLAB files to my e-mail address mathias.magdowski@ovgu.de. If you do so, please: - don't forget to attach the (preferably zipped) code to the mail - clearly indicate the main program or script to run - make sure (if possible) that it runs on your computer without problems/errors - meaningfully comment every single line of code - describe what the program should do, what to expect as the output and any discrepancy from that - don't send me files, which are not necessary - have questions as specific as possible
@maryclairerabanal267
@maryclairerabanal267 Жыл бұрын
Hello Sir, I have an earthquake vibration data from an accelerometer installed in a building. I'm supposed to get the natural frequency of the structure by doing fft analysis. However, the data seem to be erratic and is far from expected output. Could you please help me? Thank you very much
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
Thanks for your inquiry. You may send me your data to my e-mail address mathias.magdowski@ovgu.de with a clear description of your exakt problem and I might have a look, but I'm rather busy at the moment.
@user-ph2gx8gx7v
@user-ph2gx8gx7v 10 ай бұрын
Hi sir, I have the vibration data to diagnose the bearing fault can I use the same code for FFT
@MathiasMagdowski
@MathiasMagdowski 10 ай бұрын
Thanks for the question. You probably can use the very same code to calculate the spectrum of your sampled vibration signals in a straightforward manner. The bigger challenge will then be to detect a bearing fault from the spectrum itself. A fault in the bearing might lead to stronger vibrations (so a larger amplitude), to a shift of resonant frequencies or might lead to the generation of new frequency components which were not present in the spectrum before. You will certainly need to capture vibration data with different faulty and faultless bearings for comparison and validation of robustness and repeatability of your method.
@radon3292
@radon3292 3 ай бұрын
Why is the name of the Y axis is maximum periodic change of acceleration in m/s^2? It is not jerk, since units are in acceleration. Thus why change? Is it just amplitude of vibration at particular frequency? Thanks!
@MathiasMagdowski
@MathiasMagdowski 3 ай бұрын
Yes, you are probably right that my terminology might be a bit misleading here. The rate of change (or time derivitive) of the position (in m) is the velocity (in m/s). The rate of change (or time derivitive) of the velocity (in m/s) is the acceleration (in m/s²). The rate of change (or time derivitive) of the acceleration (in m/s²) is the jerk (in m/s³). Nevertheless, what I called "periodic change" or "maximum periodic change" is just the amplitude or "change", not the "rate of change" or time derivitive of the corresponding quantity, i.e. position, velocity and acceleration.
@aryashah7892
@aryashah7892 11 ай бұрын
Hello Sir, I am having trouble while performing fourier transform of position (x_t). While using 'fourier' command exactly as you coded "[f,X_f]=fourier(t,x_t,'sinus');" I'm getting an error stating 'Incorrect number or types of inputs or outputs for function 'fourier'.' Could you please explain me the issue here, and what can be done to overcome this?!!
@MathiasMagdowski
@MathiasMagdowski 11 ай бұрын
Thanks for your question. I would assume, that the input variables t or x_t are not correct in your case. Both t and x_t must be plain numeric vectors with the same length. The time vector t should be given in the unit s, must start with 0 and must have equidistant time steps as described in the comments of the function. If t or x_t are cell arrays, tables, structs or something else, the fourier.m function might not work as expected or might not work at all. You can check the nature of your input variables t and x_t in the MATLAB workspace or variable editor.
@aryashah7892
@aryashah7892 10 ай бұрын
@@MathiasMagdowski Thank you for your response sir. I am dealing with signal analysis form sample data sets of accelerometer to analyse the vibrations occurred while collision of a leg prosthesis against a stair. In between I had a question, how to do bode plots and get cut off frequency when we don't have for instance 'sine signal' generated directly from the matlab function(x = sin(2*pi*f*t))? Instead we have data sets of acceleration and time and that have been used to plot signal. In this case of datasets how could we apply bode plots formulation?
@MathiasMagdowski
@MathiasMagdowski 10 ай бұрын
@@aryashah7892 A Bode plot is nothing more than a combination of two plots showing the magnitude and phase as a function of frequency, see: en.wikipedia.org/wiki/Bode_plot Typically, both the frequency axes as well as the magnitude axis are logarithmically scaled, while the phase axis is linearly scaled. Bode plots are usually used for transfer functions or impedance operators, but you can also use if for the spectrum of a signal. If your time-domain data is sampled correctly (not undersampled, capturing a whole aperidodic impulse or more than one period of the fundamental frequency of a periodic function, proper amplitude resolution, not only noise, no trend, no amplitude jump from the beginning to the end or proper windowing), you should see one main or several spikes, peaks or resonances in your magnitude spectrum. These will be the frequencies of the vibrations occuring during or after the collision. For high frequencies, the magnitude should usually go down into the noise floor. You could define a cut-off frequency between the "resonance" region and the "noise" region.
@mowzafmouwad7898
@mowzafmouwad7898 2 ай бұрын
I am just wondering at the video minute 5:56 you showed the graph of position which i believe you mean displacement, is it normal to be 150 meters? I was performing similar analysis and got even much bigger value and I find it weird somehow. Thank you
@MathiasMagdowski
@MathiasMagdowski 2 ай бұрын
The position is determined by integrating the velocity over time, which in turn is determined by integrating the measured acceleration over time. Any small measurement error or uncertainty in the acceleration will result in a linearly increasing deviation in velocity, which in turn will result in a quadratically increasing deviation in position. To avoid this, careful filtering or detrending of the data is required. This is the purpose of the procedure presented in the video.
@mowzafmouwad7898
@mowzafmouwad7898 2 ай бұрын
Thank you for the reply, I have just noticed that when using the cumtrapz the data is cumulative. If I am willing to get the displacement at each point instead of the cumulative what do you suggest? I have been trying trapz however I had errors in matlab code and didn't work. Thank you again
@MathiasMagdowski
@MathiasMagdowski 2 ай бұрын
​@@mowzafmouwad7898 Thank you for your further question. I think you are misinterpreting the results of the functions cumtrapz (de.mathworks.com/help/matlab/ref/cumtrapz.html) and trapz (de.mathworks.com/help/matlab/ref/trapz.html). The result of the cumtrapz function is again an array or vector containing the primitive or antiderivative function of an input array or vector. The result of the trapz function is simply the resulting integral, i.e., a scalar number. See this simple example of integrating the cos function, which approximately gives the sin function and the final integral over a full period which is (almost) zero. >> x=linspace(0,2*pi,13) x = 0.00000 0.52360 1.04720 1.57080 2.09440 2.61799 3.14159 3.66519 4.18879 4.71239 5.23599 5.75959 6.28319 >> y=cos(x) y = Columns 1 through 11: 1.0000e+000 8.6603e-001 5.0000e-001 6.1230e-017 -5.0000e-001 -8.6603e-001 -1.0000e+000 -8.6603e-001 -5.0000e-001 -1.8369e-016 5.0000e-001 Columns 12 and 13: 8.6603e-001 1.0000e+000 >> cumtrapz(x,y) ans = 0.00000 0.48852 0.84615 0.97705 0.84615 0.48852 0.00000 -0.48852 -0.84615 -0.97705 -0.84615 -0.48852 -0.00000 >> trapz(x,y) ans = -1.6653e-016
@MathiasMagdowski
@MathiasMagdowski 2 ай бұрын
In short, if the cumtrapz function doesn't help you, the trapz function won't either, because the result of the trapz function is also included in the output of the cumtrapz function (i.e., in the last element of the output vector): >> cumtrapz(x,y)(end) ans = -1.6653e-16 >> trapz(x,y) ans = -1.6653e-16
@AvinashAyyalasomayajula
@AvinashAyyalasomayajula 9 ай бұрын
Once we convert a time wave form signal into a FFT spectrum, how can we extract the fewtures from the FFT.
@MathiasMagdowski
@MathiasMagdowski 9 ай бұрын
The question is, what you define as a feature. The spectrum calculated by the FFT algorithm contains the amplitudes and phases of the sinusoidal (or better cosinusoidal) functions that you need to replicate the time function with respect to the different frequencies. You will nicely see if your signal contains only a few certain frequencies or is rather broadband. If the signal or time function is the output of a system, you might also see resonances, natural frequencies or eigenfrequencies of the system. The question remains, what you define as a feature.
@berfindurmus9380
@berfindurmus9380 5 ай бұрын
hi tank u for valuable information i use accelerometer and i need to calculate and plot detailed frequency centered distribution can y give me some advices and direction
@berfindurmus9380
@berfindurmus9380 5 ай бұрын
Depending on the frequency intensity I want to detect the moments of signal distortion i will use for motors i guees i need to make vibration analysis
@MathiasMagdowski
@MathiasMagdowski 5 ай бұрын
​@@berfindurmus9380 What do you exactly mean by a "frequency-centered distribution"? Maybe these more general videos are also helpful for you: How to do a discrete Fourier transform (FFT) and to plot the amplitude and phase spectrum in MATLAB kzfaq.info/get/bejne/kNyJetSKtN_Jo58.html How to scale the result of the fft (fast Fourier transform) and how does fourier.m work in MATLAB? kzfaq.info/get/bejne/nqeSptKJxsCVZGg.html How to reconstruct a periodic signal as a sum of cosine functions from the freq. spectrum in MATLAB kzfaq.info/get/bejne/hdyph7Wpv7nTnIk.html
@berfindurmus9380
@berfindurmus9380 5 ай бұрын
@@MathiasMagdowski i will check the contents thank u for feedbacks
@MathiasMagdowski
@MathiasMagdowski 5 ай бұрын
​@@berfindurmus9380 You are welcome.
@JohnBo199
@JohnBo199 4 ай бұрын
Hello I would like to use my Raspberry Pi and an accelerometer to monitore the vibrations at a robot arm . So I get acceleration values from all three axes x,y,z over time when I start the process including the acceleration due to gravity g depending on how the sensor is oriented. What do I do with the acceleration due to gravity, because when the system is horizontal at rest it experiences about 0 m/s^2 on the x and y axis at rest and the z-axis understandably 9.81 m/s^2. How do I deal with this when the acceleration values of the vibration are added to this? Do you have any idea how I can calculate the displacement from the three data values? Should I record each axis individually and then look at the values and integrate twice? Or do you have another idea and should I consider the interaction of the three axes? Thank you very much :) I really liked your explanations :)
@MathiasMagdowski
@MathiasMagdowski 4 ай бұрын
Thanks for this excellent question. I would also need to think about this problem a little longer, but I would argue that if you are rotating your accelerometer you cannot really use it anymore to obtain an absolute position as even a linear movement along a straight line might be measured with changing parts into the x, y and z component of the acceleration. To compensate this effect, you would also need a three-axis gyroscope that ideally uses the same sampling rate, so that you could convert the rotating Cartesian coordinate system of your moving and rotating accelerometer to a fixed, absolute Cartesian coordinate system of the environment. If you only want to analyze the rapid vibrations, I would simply remove the constant part of each component of your measured time-dependent acceleration individually, e.g. by subtracting the mean value. I would assume that your vibration happens much faster than the movement of the robot arm itself, so you only need to look at short sections of your time function, long enough to capture the vibrations, but short in comparison with the arm movement. You can also do a Fourier transform and then simply remove the constant part there. After integrating the time function twice or after dividing the spectrum by j*omega twice, you should obtain the time function or spectrum of the displacement.
@JohnBo199
@JohnBo199 4 ай бұрын
@@MathiasMagdowski I send you an mail, because i got another question. Maybe you can help me out there. Lovely greetings.
@MathiasMagdowski
@MathiasMagdowski 4 ай бұрын
@@JohnBo199 Thanks, I have received it well.
@SHOHOB2000
@SHOHOB2000 2 ай бұрын
hello sir, at 4:00 I "nearly" have the same problem but in a different case So, I have an accelerometer put on car, and I'm asked to integrate it's output to get velocity. Now velocity should return back to zero because car eventually stops but this doesn't happen instead velocity stabilizes at -ve value The problem is detrend won't solve this issue because in your case a vibrating object must be periodic motion meaning it's oscillating around zero position so we know for a fact that it's slope should be zero but in mu case it's different as the car can go anywhere and isn't periodic motion and I'm struggling to fix this issue If you need to know the sensor it is inside a phone (we are using the accelerometer inside it) labeled lsm6dsm ACCELEROMETER thanks in advance for the helpful tutorial :)
@MathiasMagdowski
@MathiasMagdowski 2 ай бұрын
Thanks for your question. What do you exactly mean by the '-ve value', at which the velocity stabilizes if the car stops? In your case, I would assume that the acceleration should be almost zero and very stable, if the car really stopped, because you should then only see small vibrations due to the running motor or something similar. Such small and stable values of the acceleration should be very uncommon in normal driving conditions, except for a very smooth road and very constant driving speed. So I would suggest to try to detect very small and very stable values of the acceleration by some well-defined criterion, under which the car can be assumed to have come to a full stop. In this case you just reset your integrated (and possible erronous) velocity back to zero. Let me know if this helps.
@charanchaganti1635
@charanchaganti1635 14 күн бұрын
Hi, I have BNO055 acceleration data mounted on a vehicle, I need to calculate velocity and position from this data, please help
@MathiasMagdowski
@MathiasMagdowski 14 күн бұрын
I have no experience with the mentioned accelerometer, but you might send me a sample of your data and your well-commented program to my e-mail address mathias.magdowski@ovgu.de
@rwaewae
@rwaewae Жыл бұрын
How do we apply wavelet coherence in Matlab? thanx
@MathiasMagdowski
@MathiasMagdowski Жыл бұрын
To be honest, I have no clue about wavelet coherence and how to apply it in MATLAB.
@asifraj321
@asifraj321 5 ай бұрын
Sir, i have data points (t,V) of blood flow waveform. I want to fit this data with the help of fft. The matlab tool did't accurately fit with eight co-efficient.Could you help me regarding this?
@MathiasMagdowski
@MathiasMagdowski 5 ай бұрын
Sure, you can send me your data to my e-mail address mathias.magdowski@ovgu.de and I might have a look. Why do you want to have exactly eight coefficients?
@asifraj321
@asifraj321 5 ай бұрын
Thank you for your prompt response, sir. We require more than eight coefficients to precisely fit the data. However, the MATLAB curve fitting tool offers only up to eight coefficients by default, which is why we are seeking your assistance. I am sending you the data
@MathiasMagdowski
@MathiasMagdowski 4 ай бұрын
@@asifraj321 I have had a look at your problem. The question is, why you do want to use the curve-fitting toolbox to do the Fourier analysis and why you not simply do it by yourself using the method presented in my video. There is also another video explaining the Fourier reconstruction, which might be also very interesting for you: "How to reconstruct a periodic signal as a sum of cosine functions from the freq. spectrum in MATLAB" kzfaq.info/get/bejne/hdyph7Wpv7nTnIk.html Anyhow, I have prepared a short script that uses my fourier.m function to do the FFT analysis of your data. It reads it your time-domain data, plots it, does a Fourier analysis, plots the spectrum and does a Fourier reconstruction based on the N most important spectral components. You can enlarge this number to achieve a better fit. The corresponding amplitudes and phases of these harmonics are printed to the MATLAB command line while running the script as in the above-mentioned video. You can compare theses results with the results of the curve-fitting toolbox. In my script, the harmonics are given by amplitude and phase, in the toolbox by the coefficients a for cosine functions and b for sine functions. You can calculate or convert them by a=amplitude .*cos(phase) b=-amplitude .*sin(phase) You do not get exactly the same results, but the outcome is quite close. As you mentioned, the curve-fitting toolbox only allows to obtain 8 harmonics or 2 * 8 = 16 coefficients plus the constant part. My function fourier.m allows to obtain also higher numbers of harmonics or coefficients. If your time function has e.g. 200 values, you would also get 100 harmonics (plus the constant part). If you use all these harmonics for the reconstruction, you would also get a perfect fit. The question therefore is, how many harmonics or how many coefficients you really need to get a reasonable agreement and to perform your intended analysis and further processing of the results. If you use too many harmonics and coefficients, there is clearly the danger of over-fitting your data.
@asifraj321
@asifraj321 4 ай бұрын
Thank you for explaining in detail. It's very helpful.
@mediwise2474
@mediwise2474 Ай бұрын
Pl help i want yo convwrt vibration damping data in frequency vs amplitude to time domain
@MathiasMagdowski
@MathiasMagdowski Ай бұрын
First, please fix your keyboard or use a spell checker. Second, please have a look at this video on how reconstruct a periodic signal as a sum of cosine functions from the corresponding frequency spectrum in MATLAB: kzfaq.info/get/bejne/hdyph7Wpv7nTnIk.html Please note that this will only work if you have a full complex-valued spectrum given as a real part and imaginary part or by amplitude and phase of all the relevant spectral components. If you just have an amplitude spectrum without any phase information, you cannot usually not fully reconstruct the corresponding time-domain signal.
@mediwise2474
@mediwise2474 Ай бұрын
@@MathiasMagdowski sir is this video enough for conversion
@MathiasMagdowski
@MathiasMagdowski Ай бұрын
@@mediwise2474 Is this a question or a statement? In any case, I guess that you will have to find this out yourself for your problem.
@mediwise2474
@mediwise2474 Ай бұрын
@@MathiasMagdowski sir I'm a student of textile science with no knowledge of matlab thqts why asking it sir
@mediwise2474
@mediwise2474 Ай бұрын
@@MathiasMagdowski actually question is is this a procedure to convert frequency domain graph or value of a vibration damping to a time domain sir ?
@radon3292
@radon3292 4 ай бұрын
Why not use fft Matlab command?
@MathiasMagdowski
@MathiasMagdowski 4 ай бұрын
The 'fft' function (fast Fourier transform or discrete Fourier transform) is used within the 'fourier' function, which works like an API (application programming interface) or a wrapper to the underlying 'fft' function. The problems or issues with the basic 'fft' function are the following: 1. The 'fft' function only takes one argument as input, the values of the time function, and returns one output variable, the values of the spectrum. 2. Therefore, you have to take care about the corresponding time steps and frequency values yourself. The highest frequency corresponds to the shortest time, while the smallest frequency corresponds to the longest time. The 'fourier' function takes care of this. As a second input argument, you input corresponding time (equidistant) steps and get back the corresponding (equidistant) frequencies as a second output vector. 3. The ordering of the frequencies in the output vector of the basic 'fft' function is kind of strange. The first entry in the spectrum obtained by the 'fft' function refers to the doubled constant part of the transient signal. It is followed by the positive frequencies in ascending order up the the highest frequency. Then, there are the negative frequencies in descending order. Negative frequencies only make sense for complex-valued time functions, which usually have no physical meaning in the engineering sciences. For real-valued time functions, the spectrum of the negative frequencies is the complex conjugate of the spectrum of the positive frequencies. Therefore, the negative frequencies can be omitted, as they are redundant and do not contain any relevant information in that case. 4. The amplitude or magnitude of the spectrum calculated by the basic 'fft' function depends on the number of steps or vector length of the given time function. The wrapper provided by the 'fourier' function takes care of this and renormalizes the amplitude for two different cases, periodic functions (like sums of sine and cosine functions, rectangular pulse trains or clock signals) or aperiodic functions (like single pulses).
@radon3292
@radon3292 4 ай бұрын
@@MathiasMagdowski thank you for your prompt and detailed answer!
Understanding the Discrete Fourier Transform and the FFT
19:20
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 20 МЛН
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 15 МЛН
Василиса наняла личного массажиста 😂 #shorts
00:22
Денис Кукояка
Рет қаралды 9 МЛН
The Fourier Series and Fourier Transform Demystified
14:48
Up and Atom
Рет қаралды 787 М.
IMU Data Analysis: Acceleration | Live Video Sync
8:19
LEOMO
Рет қаралды 23 М.
Fourier Transforms FFT in MATLAB | MATLAB Tutorial
24:03
Phil Parisi
Рет қаралды 33 М.
Time and frequency domains
9:43
Mike X Cohen
Рет қаралды 92 М.
The Fast Fourier Transform (FFT): Most Ingenious Algorithm Ever?
28:23
But what is the Fourier Transform?  A visual introduction.
20:57
3Blue1Brown
Рет қаралды 10 МЛН
B3355 - Velocity and Position from Acceleration Data
6:37
barkerds
Рет қаралды 23 М.
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 20 МЛН