Filter löschen
Filter löschen

How to find the horizontal distance between change point lines?

2 Ansichten (letzte 30 Tage)
Carlos
Carlos am 18 Jul. 2023
Kommentiert: Carlos am 18 Jul. 2023
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

Akzeptierte Antwort

Voss
Voss am 18 Jul. 2023
diff(x_long(changeIndices))

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by