Locating the point of change in slope on beach profile
6 views (last 30 days)
Show older comments
Is anyone aware of how to best determine the location where there is a change in slope of a beach profile?
I have data that represents a beach profile, starting at a certain point landward of dunes and moving offshore below water, and would like to create a script that is able to tell me the inflection point of the beach slope.
I have used various scripts to do so, but seeing as my profiles are not monotonic functions, I am having issues. Additionally, as you can see in my attached image, there are areas seaward (to the righthand side of the image) that are variable before the general slope increases. I would like a script to be able to locate around where I have signaled with the data cursor for each profile and am uncertain of if it is a possibility.
Any ideas?
(I have attached my .mat file, VarName4 is Distance Down Line on the x-axis, VarName5 is height)
0 Comments
Answers (1)
Star Strider
on 1 Feb 2016
I would use the gradient function to identify the inflection points, and the del2 function to characterise them as maxima or minima.
Another option (depending on how smooth your data are) would be to use polyfit, and if the fit is acceptable, polyder to calculate the derivatives. The roots function would then help you find the inflection points.
2 Comments
Star Strider
on 1 Feb 2016
It took a while for me to come up with a functional approach to your problem, that being a Savitzky-Golay filter of your original data. You will need the Signal Processing Toolbox for this, but it does work. Your signal has a significant amount of broadband noise, so more typical signal processing approaches (such as discrete filtering) won’t work because much of the noise remains in the filtered signal.
openfig('Aundrea Dolan prof.fig'); % Open ‘.fig’ File
Ln = findobj(gca, 'Type', 'line'); % ‘Line’ Object
D = get(Ln, 'XData'); % Distance
H = get(Ln, 'YData'); % Height
Xst = [mean(diff(D)); std(diff(D))]; % Statistics On ‘D’
Hsg = sgolayfilt(H, 7, 201); % Savitzky-Golay Filter
dHsgdD = gradient(Hsg,Xst(1)); % First Derivative
d2Hsgdt2 = del2(Hsg,Xst(1)); % Second Derivative
figure(2)
plot(D, H, 'LineWidth',1.2)
hold on
plot(D, Hsg, 'LineWidth',0.9)
plot(D, dHsgdD * 1E+2, 'g', 'LineWidth',1)
plot(D, d2Hsgdt2 * 1E+3)
hold off
grid
legend('Data', 'Savitzky-Golay Filtered Data', 'S-G Derivative (x10^2)', 'S-G Second Derivative (x10^3)', 'Location','E')
You didn’t upload your .mat file, but I was able to get the information from your .fig file.
It’s the best I can do. You may want to experiment with it to get the result you want.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!