How to select the starting point of a curve and tare all x, y plot data to this point

32 ビュー (過去 30 日間)
Hi all,
I am looking to select the starting point of my curve and tare all x,y data to this point.
I tried using the 'findchangepts' function but this doesn't always select the correct point.
Is there an automated function to do this or a way to select the correct point directly from the plot?
T = readtable('sample1.xlsx');
X=T{:,1};
Y=T{:,2};
figure(1)
plot(X, Y)
  4 件のコメント
darova
darova 2021 年 4 月 5 日
Can you show the result you want to obtain?
Rachel Cahalane
Rachel Cahalane 2021 年 4 月 6 日
I mean transform all the data from the identified starting point back to the origin (0,0).
Like the following:

サインインしてコメントする。

採用された回答

Chad Greene
Chad Greene 2021 年 4 月 5 日
Perhaps you could find the index of the location where the chage in Y exceeds some critical threshold. You'll have to manually tune the threshold, but consider this case:
X = 1:6;
Y = [0 0 0 1 2 3];
plot(X,Y,'o-')
Find the index of the first location where the change in Y begins:
ind = find(gradient(Y)>0.1,1)
ind = 3
That says the curve begins at the third element. Now I'm not sure what you mean by 'tare', but you can subtract the values at the start of the curve to put the origin at zero, like this:
X = X - X(ind);
Y = Y - Y(ind);
plot(X,Y,'o-')
Or you could delete the first values from the arrays:
X(1:(ind-1)) = [];
Y(1:(ind-1)) = [];
plot(X,Y,'o-')
  1 件のコメント
Rachel Cahalane
Rachel Cahalane 2021 年 4 月 6 日
Thank you.
I think the gradient approach may not work for me, however I can label points on the plot to determine the correct x-range:
T = readtable('sample1.xlsx');
X=T{:,1};
X=times(X,1000)
%convert to ensure that all values are integers
Y=T{:,2};
figure(1);
plot(X, Y);
%for example the desired x-range is 3938-5995
X(1:(3938-1)) = [];
Y(1:(3938-1)) = [];
figure(2)
plot(X,Y);
How can I also delete all the values greater than 5995 from the plot?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by