How to find the horizontal distance between change point lines?
5 views (last 30 days)
Show older comments
I am trying to use MATLAB to automatically calculate a distance within a graph for a project. I decided to use the find change points function and got vertical lines displaying the points I desired. What I am now wondering is if there is a way to find the horizontal distance between the lines. My code is attached and a picture of what I am trying to find.
rawTable = readtable('Data.xlsx')
x_long = rawTable.x
AVPD_s = rawTable.y
figure;
plot(x_long, AVPD_s)
% Find change points
changeIndices = ischange(AVPD_s,"linear","SamplePoints",x_long);
% Display results
figure
plot(x_long,AVPD_s,"Color",[77 190 238]/255,"DisplayName","Input data")
hold on
% Plot change points
x = repelem(x_long(changeIndices),3);
y = repmat([ylim(gca) missing]',nnz(changeIndices),1);
plot(x,y,"Color",[51 160 44]/255,"LineWidth",1,"DisplayName","Change points")
title("Number of change points: " + nnz(changeIndices))
hold off
legend
xlabel("x_long","Interpreter","none")
clear x y
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!