Intersection point between two graphs
Show older comments
Hello. I am new in using matlab. I need to find the intersection threshold between fx1 and fx2. I also need to find the midpoint of the two max points.
Here is the code.
% get histogram normalized to pdf & superimpose pdf obtained ksdensity
no_target = data(1:60);
target = data(61:110);
figure, histogram(no_target, 'normalization', 'pdf')
hold on
histogram(target, 'normalization', 'pdf')
xx=0:0.25:1.2*max(data);% get the x-coordinates to get the ksdensity
fx1=ksdensity(no_target,xx);
plot (xx, fx1,'-r', 'linewidth',1.5)
fx2=ksdensity(target,xx);
plot (xx, fx2,'-g', 'linewidth',1.5)
idmax1=find(fx1==max(fx1));
idm1=round(median(idmax1));% needed, there is more than one value of the index
plot(xx(idm1),fx1(idm1),'b*');
idmax2=find(fx2==max(fx2));
idm2=round(median(idmax2));% needed, there is more than one value of the index
plot(xx(idm2),fx2(idm2),'r*');
xlabel('values'), ylabel('estimated density')
legend('H_0 (Target Absent)','H_1 (Target Present)', 'fit(H_0)', 'fit(H_1)', strcat('max(H_0)=', num2str(max(fx1))), strcat('max(H_1)=', num2str(max(fx2))))
Answers (1)
Star Strider
on 23 Jan 2021
0 votes
Categories
Find more on Exploration and Visualization 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!