Azzera filtri
Azzera filtri

How to find the horizontal distance between change point lines?

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Voss
Voss il 18 Lug 2023
diff(x_long(changeIndices))

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by