Finding lapse rate (value for dT/dh) - matlab

I have a temperature dataset with surface temperatures and a second dataset with the corresponding elevation at which these temperatures are measured. How can I find the aprroximate lapse rate between those 2 datasets? I can use MatLab but I don't know what to do.
So dT/dh = ...?
Thanks!

Related

how to calculate and plot the fast fourier transform of sla data (3 d matrix) in 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.

How to predict temperature for the 4th day, given temperatures for previous days, using a linear perceptron?

I have four sets of data (3 for training, 1 for testing) that include the hour of the day and temperatures in this format:
Time | Temperature
5, 60
6, 63
7,70
8,73
9,78
10,81.5
11,85.1
12,87
13,90
I need to train and test a perceptron and then predict what the temperatures will be on the next day at the same hours.
I am trying to use Matlab to do this and I know I am supposed to normalize the data and use time-series prediction. However I can't figure out how to start.
I don't understand what the inputs and outputs are, and what activations function to use to make the output linearly from -infinity to +infinity.
I'm pretty sure you won't have to use a perceptron for this task as you want to perform regression and not classification. (Perceptron is a binary classifier see Matlab documentation.)
To start with normalization: You need to adjust your data such that the mean is zero and the standard deviation equals 1. For example:
data = rand(1,100);
data = (data - mean(data))/sqrt(var(data));
You can interpret your input and output as follows:
You have an underlying function which maps your time-values to the temperature values (f:time->temperature). Time is the independent variable and temperature the dependent variable (see for example Wikipedia). And you want to find an approximation for f based on your input data.
For time series regression you will find a detailed example here. If you
are required to use a feedforward network you can also take a look at this.

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:-

compute time series weighted average

I have a 8760x1 vector with the 1-hour average ambient temperature time series.
I want to calculate the weighted average temperature weighted by the percentage of operating
hours at each temperature level.
What i thought is divide the temperature range with:
ceil(Tmax-Tmin)
and then use hist.
Are there any other suggestions?
Thank you in advance.
mean(temperatures) should do it.
Since you have hourly measurements, the frequency of a given value will be reflecting the operating hours at that temperature level. A value that occurs frequently will therefore automatically have more weight in the average.
Let's say you have two vectors that are the same length, one is the temperature (temp), and the other is the amount of time at that temperature (time_at_temp). The weighted average formula is this:
wt_avg_temp = sum(temp .* time_at_temp) / sum(time_at_temp);

analyse time series at a specific frequency

I have a long data set of water temperature:
t = 1/24:1/24:365;
y = 1 + (30-1).*rand(1,length(t));
plot(t,y)
The series extends for one year and the number of measurements per day is 24 (i.e. hourly). I expect the water temperature to follow a diurnal pattern (i.e. have a period of 24 hours), therefore I would like to evaluate how the 24 hour cycle varies throughout the year. Is there a method for only looking at specific frequencies when analyzing a signal? If so, I would like to draw a plot showing how the 24 hour periodicity in the data varies through the year (showing for example if it is greater in the summer and less in the winter). How could I do this?
You could use reshape to transform your data to a 24x365 matrix. In the new matrix every column is a day and every row a time of day.
temperature=reshape(y,24,365);
time=(1:size(temperature,1))-1;
day=(1:size(temperature,2))-1;
[day,time]=meshgrid(day,time);
surf(time,day,temperature)
My first thought would be fourier transformation. This will give you a frequency spectrum.
At high frequencies (> 1/d) you would have the pattern for a day, at low frequencies the patter over longer times. (see lowpass and highpass filter)
Also you could go for a frequency/time visualization that will show how the frequencies change over a year.
A bit more work - but you could write a simple model and create a Kalman filter for it.