How can I match a value on a matlab plot?

5 ビュー (過去 30 日間)
Julia de Lange
Julia de Lange 2018 年 1 月 11 日
コメント済み: Star Strider 2018 年 1 月 12 日
I have identified the first peak value in my dataset. I'd like to know the first x-value at the point at which this peak y-value occurs again. Any suggestions? p

採用された回答

Star Strider
Star Strider 2018 年 1 月 11 日
編集済み: Star Strider 2018 年 1 月 11 日
Use the ‘locs’ value:
[pks,locs] = findpeaks(Voltage, 'MinPeakDist',2000, 'NPeaks',1);
peakTimes = Time(locs);
See the plot call in my previous code to demonstrate how to do this.
EDIT
‘I'd like to determine x (time) the next time 1.4147 (y, voltage) occurs.’
This will give all the ‘Voltage’ and ‘Time’ values that equal or exceed the initial peak value:
[D,S,R] = xlsread('Data.xls');
Time = D(:,1);
Voltage = D(:,2);
[pks,locs] = findpeaks(Voltage, 'MinPeakDist',2000, 'NPeaks',1, 'MinPeakHeight',1.2);
VoltageThreshold = Voltage - pks*0.99;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
zx = zci(VoltageThreshold);
TimeNew = Time(zx); % Time Vector, Voltage >= VoltageThreshold
VoltageNew = Voltage(zx); % Voltage Vector, Voltage >= VoltageThreshold
figure(1)
plot(Time, Voltage)
hold on
plot(Time(locs), Voltage(locs), '+g')
plot(TimeNew, VoltageNew, '+r')
hold off
grid
  12 件のコメント
Julia de Lange
Julia de Lange 2018 年 1 月 12 日
worked, thank you!
Star Strider
Star Strider 2018 年 1 月 12 日
As always, my pleasure!

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

その他の回答 (1 件)

SRT HellKitty
SRT HellKitty 2018 年 1 月 11 日
Say you have data with peaks for the Y-Axis and linear data for the X-Axis
Y = [1:5,1:5,1:5];
X = [1:15];
Now you have 3 peaks in Y, when it equals 5. If you want to know what value of X is when Y is equal to 5 you could do a logical index;
X_at_peaks = X(Y == 5);
That would show that X is 5, 10, and 15 when Y is equal to 5.
  2 件のコメント
Julia de Lange
Julia de Lange 2018 年 1 月 11 日
編集済み: Julia de Lange 2018 年 1 月 11 日
Let me give you more details. I have attached my data with one time (x) plotted versus voltage (y). I have found the first peak to occur at (1.037,1.4147). I'd like to determine x (time) the next time 1.4147 (y, voltage) occurs.
SRT HellKitty
SRT HellKitty 2018 年 1 月 11 日
If voltage is exactly 1.4147 another time in the data, do the logical indexing with respect to time
Peaks = time (Voltage == 1.4147)

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by