How to find the horizontal distance between change point lines?

5 次查看(过去 30 天)
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

采纳的回答

Voss
Voss 2023-7-18
diff(x_long(changeIndices))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by