get the correct data of intersection in plot

11 views (last 30 days)
Hi, I'm working on a project in which i want to know the time on which the accuracy lines hit 95% for the first time. I've already looked in some related topics but didn't find any that could help me on it.
Although the figure below contains two sets of lines only the accuracy ones are of importance.
below a simplified representation of the code for this graph.
frequencies = [7.5 15 30 60 120 240];
nfrequencies = numel(frequencies);
duration = 0.2:0.2:8.5;
for a=1:nfrequencies
accuracy(:,a)=(a+2)*(a+2.5)*duration+10;
ltext{a}=[num2str(frequencies(a)), 'Hz'];
end
plot(duration,accuracy)
axis([0.2 8.5 0 102])
legend(ltext,'Location','southeast');

Accepted Answer

Jacco vD
Jacco vD on 15 Aug 2016
none of those seem to work this case.
So I fixed it simply like this. It gives me the first time that the accuracy of a given frequency is 95%, which is what in need;)
duration = 0.2:0.2:8
nfrequencies = 6
threshold = accuracy*100>=95;
X = zeros(nfrequencies,1)
for l=1:nfrequencies
fthreshold = find(threshold(:,l));
if fthreshold >= 1
Y = duration(fthreshold(1));
else
Y = max(duration);
end
X(:,l)= Y;
end

More Answers (1)

Thorsten
Thorsten on 5 Aug 2016
You can compute the first intersection of each curve with a horizontal line of height 95. There are various ways to compute intersections, as described in http://blogs.mathworks.com/pick/2011/09/09/detect-curve-intersections-quickly-and-easily/?s_tid=srchtitle

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!