Threshold in my plot.

조회 수: 15 (최근 30일)
Kaique Silva
Kaique Silva 2015년 6월 10일
편집: phdcomputer Eng 2019년 1월 4일
I have a plot (Amplitude vs time), and I want to obtain the first time determined amplitude appears in my plot. Let's say I have my plot, and the amplitude ranges from -1 to 1, and I decide that the threshold is 0.5, it means that I want to know the time (x-value) that this amplitude was first recorded. How can I do it?

채택된 답변

Image Analyst
Image Analyst 2015년 6월 10일
Try this:
% Find where Amplitude first exceeds 0.5:
firstIndex = find(Amplitude > 0.5, 1, 'first');
% Get Amplitude at that index:
amplitudeAtThresh = Amplitude(firstIndex);
% Get time at that index:
timeAtThresh = t(firstIndex);
  댓글 수: 2
Kaique Silva
Kaique Silva 2015년 6월 10일
Thank you very much, it worked!
phdcomputer Eng
phdcomputer Eng 2019년 1월 4일
편집: phdcomputer Eng 2019년 1월 4일
@ImageAnalyst I wanted to ask you If this solution is practical for my problem?
I computed the average of distances between each column and other columns in a matrix except itself. (the matrix is nxm size) Then I plotted the distances and I'm trying to empirically obtain the point where the distance values start to decrease but the figure doesn't show this. I attached the figure of distances. I don't know what should I define x-axis and y-axis.
close all;
clc
load lung.mat
a=lung;
[n,m]=size(a);
For i=1:m
For j=1:m-1
If(i==j)
d=0;
Else
d=pdist2(a(:,i),a(:,j),'jaccard');
s=sum(d)/(m-1);
End
End
End
figure,plot(s),title('jaccard distances')
I wanted to know how to define a formula to find the start point of values' decreasing?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Joseph Cheng
Joseph Cheng 2015년 6월 10일
편집: Joseph Cheng 2015년 6월 10일
use the function find and any logical operators to determine the position in the array you are at/above/below the threshold.
amp = -1:.1:1;
time = 1:numel(amp);
thres = .5;
tsample = find(amp==thres);
figure,plot(time,amp,time(tsample(1)),amp(tsample(1)),'rx')
you didn't mention crosses, above, and/or below in your question but at the threshold. so i used the == to determine when you are at the threshold. If there is more to the question about detecting rising and falling edges threshold the signal using the threshold and then use diff() to determine positive or negative transitions.
  댓글 수: 3
Joseph Cheng
Joseph Cheng 2015년 6월 10일
편집: Joseph Cheng 2015년 6월 10일
very true, but is time() a built in function? I air coded the above and just opened matlab to check the doc on time() but found nothing. Which toolbox is it in?
Image Analyst
Image Analyst 2015년 6월 11일
It's in base MATLAB, at least it's in the R2015a version:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Detection에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by