get the correct data of intersection in plot

4 次查看(过去 30 天)
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');

采纳的回答

Jacco vD
Jacco vD 2016-8-15
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

更多回答(1 个)

Thorsten
Thorsten 2016-8-5
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

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by