how to calculate and plot the fast fourier transform of sla data (3 d matrix) in matlab? - matlab

I want to check for the existent dominant peaks in sla data(3 d matrix lon, lat ,time) from which I can delineate what period to choose so that I can filter this data and look for waves propagating in the region. My data is for all lat and lon(global data). However, I want to average over a lon range of 70E to 100E and after that average over 10S to 10N. This average will give a a vector only in time dimension over which I can perform fast fourier transform. Then I want to plot this with time as the x axis. I'm new to matlab, any help is appreciated. Also if anyone has done this before it would be nice if you told me if my logic is correct or not.

Related

Frequency from fft data set matlab [duplicate]

This question already has answers here:
How do I obtain the frequencies of each value in an FFT?
(5 answers)
Closed 6 years ago.
I have a data set in a matrix in matlab. It contains 25,000 values taken every 0.5 ns; so the total time of the dataset is 1.25E-5 seconds.
The data set contains very high frequency noise that I am not interested in so I create another matrix is every 50th data point from the first matrix So the size of the matrix is 1000*.
I plot the absolute values from matlab's fft this matrix (I also normalise the amplitude and only plot the first half) and get the attached (two plots, second is a close up of the low frequencies I am interested in). How do I convert the x-axis to frequency?
Another point, if I take every data point (so I create an fft of the entire 25,000 points) then the x-axis is exactly the same; in other words, the size of my matrix seems to have no bearing on the x-axis returned by matlab. I've attached two links to the frequency spectrum, one of which is a close-up of the low frequencies I am interested in. It's axis goes from 0-50, so it is these values I need to convert to Hz.
Thankyou in advance!
Close up of frequency spectrum
frequency spectrum
From what I read on http://www.mathworks.com/help/matlab/math/fast-fourier-transform-fft.html#bresqop-1, it appears that the units on the x-axis of the plotted FFT are Hz if the first vector, f, you put into the plot(f,power), is defined as a sequence of n elements (n being the number of data points put into the FFT) increasing from zero to the sample frequency.
Thus, for the first plot, which used every 50th of points that were taken at a frequency of 2 GHz, the sample frequency would be 40 MHz. Thus, f = (0:n-1)*4*10^7/(25000/50)
It goes on to show how to use the fftshift function to put the center of the output of the fft function at 0, but it's clear you already did that and chopped off the negative part.
So, once you have the right separation of fs/n, sampling frequency divided by number of data points used, in the vector that supplies the x-axis to the plot function, then the units of the x-axis will be Hz.
(I hope you still have the numbers to graph again? If not, this question might help: Confusion in figuring out the relation between actual frequency values and FFT plot indexes in MATLAB)

Finding the time or rate weighted average between peaks in Matlab?

I have some data, that basically looks like a sine wave. I run that through the peak detection function to find the peaks and mins of the data:
[Maxima,MaxIdx] = findpeaks(Peak,'MinPeakHeight',mean(Peak),'MinPeakDistance',10);
Mins=1.01*max(Peak)-Peak;
[Minima,MinIdx] = findpeaks(Mins,'MinPeakHeight',mean(Mins),'MinPeakDistance',10);
Minima = Peak(MinIdx);
What I would like to do is calculate the slope between each peak and trough, and then use that slope to calculate a time weighted average minimum value and see how that method compares to the minimum value. How would I go about this?
was asked to show some data:-

Confidence intervals on the derivative of a polynomial surface

My problem is the following:
I have fit a surface to some xyz coordinate data to obtain a polynomial surface. That's a polynomial in the variables x and y giving a surface of z-values. I know how to compute 95 percent condidence intervals on the mean response and also new predicition intervals (the standard stuff). Having obtained the surface function it's also easy to determine the derivative at a certain point on the the surface however, what I'm looking for is:
How do I compute confidence levels on the derivative value dS/dx, the (partial) derivative in the x direction at a certain point?
Are there expressions for calculating such intervals similar to the intervals for the 95 percent confidence intervals on the mean response?
(Please don't bother to post an answer on the confidence interval for the slope of a simple regression line. That's not the answer to this question. Anyway, I think it isn't.)

How to measure the period between the peaks or lows of waves?

I want to measure the period between the peaks/lows of the adjacent waves shown in the figure.
This is an oscillatory behavior of calcium concentration in a cell. The peaks are not the same, hence I would need to calculate the peak/lows for each wave, obtain the corresponding time associated with the peaks/lows, and find the difference between adjacent peaks/lows. I have stored the calcium concentration values for every time "0.01".
Can anyone suggest me how I should code it? I would prefer to use smaller lines of code.
Look into the inbuilt findpeaks function that can return you the index of peaks in your signal.
You could use this to also find the lows in your signal by first squaring your signal. Something like this could work (I haven't tried this in MATLAB so there could possibly be some syntax issues):
% Square the signal so that the lows become peaks
signal = signal .^ 2;
% Get the location of the peaks in terms of t (your time vector)
[~, peaksAndLows] = findpeaks(signal,t)
% Find the difference between consecutive peaks/lows
periodsBetweenPeaksAndLows = diff(peaksAndLows);

Calculating the time period for multiple signals in matlab

I'm currently doing a fluid simulation. The flow is calculated in discretized steps of 0.0625 s. I think the flow is periodic in all points because it is periodic in some points.
I also calculated the Fourier Transform of this. There was a minor peak at 0.5356 Hz (and some more at higher frequencies). So the period is 1.8671 s. This was consistent with the corresponding signal.
But now I want to prove that this counts for all the nodes of my mesh (around 7000 nodes). Is there a fast way for doing this in MATLAB?
Thanks
(I would have loved to add pictures but I couldn't)
Yes.
If the input X is a matrix, Y = fft(X) returns the Fourier transform of each column of the matrix. This is considerably faster than looping through each column and calling fft(x) one at a time.
You will need to reshape your input data into a 2-D matrix, where the row dimension is time, for the analysis.