フィルターのクリア

How to find the horizontal distance between change point lines?

2 ビュー (過去 30 日間)
Carlos
Carlos 2023 年 7 月 18 日
コメント済み: Carlos 2023 年 7 月 18 日
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 Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by