finding coordinates from a plot

Hi there,
I have plotted some data. I can use the "Data Cursor" to get the coordinates...but its becoming tedious.. I would like know if I can use some other way to get values of my graph for y= 10^(-9) or like this. .. I think the attached jpeg file clearly states my query.
Your help is highly appreciated.
the code goes like this :
for i=1:m;
for j=1:n;
snr(j)=p(j)/N(j);
ber(j)=.5*erfc((snr(j).^.5)/(2.828));
end
semilogy(pin_dbm,ber);
ylabel('BER');xlabel('Input Power, pin(dbm)');
title('BER vs Input Power Varying Number of Hops');
grid on
hold on
end
I have tried interp1 and find functions , but could not get any success!
Thanks

Answers (2)

KALYAN ACHARJYA
KALYAN ACHARJYA on 1 Mar 2019
Edited: KALYAN ACHARJYA on 1 Mar 2019
For each plot you can do that, do that after the input power statemnet, if in loop you can get it easily
idy=find(BER==10^(-9));
x_finding=x(idy); % x represents input power
Please note that in BER array there must be 10^(-9) value, otherwise you have to calculate it using interpolation.

1 Comment

find is a waste of time here.
idy = BER == 10e-9;
x_finding = x(idy);
will work just as well. Or most likely, just as badly. As noted, 10e-9 must be present exactly in the array which is highly unlikely.

Sign in to comment.

Guillaume
Guillaume on 1 Mar 2019
Note that your loops are not needed. You could calculate all the values at once, and plot that. Even if you use a loop, repeating the ylabel, xlabel, title, and grid at each step is a waste of time. Just do it once after the loop.
In your loop, nothing depends on i, so you're drawing m times the exact same plot. That's certainly not the code you've used to plot the above. Presumably, you've simplified it but removed too much.
Assuming, 10e-9 is not found exactly in your ber array, you'll have to interpolate. That can be done easily all at once for all plots if you store the plotting data in a m x n array. To show you how to do that we need an actual working code.

2 Comments

Thanks for the help. 10e-9 is not found in my ber array, it is to be found from the plot. i need to use interpolate i know, but could not. My code is like this:
for i=1:length(Nh);
for j=1:length(pin_dbm);
snr(j)=p(j)/N(j); %p(j) depends on pin_dbm and N(j) depends on pin_dbm and Nh both
ber(j)=.5*erfc((snr(j).^.5)/(2.828));
end
q=semilogy(pin_dbm,ber);
grid on
hold on
end
Thanks in Advance
You've just repeated the code that you put in the question, which as stated is not correct. Nothing in your loop depends on i, so you'd be plotting length(Nh) times the exact same plot. The first step of getting what you want would be to build a 2D array length(Nh) x length(pind_dbm) but without seeing the depency on i, I can't tell you how to do that.

Sign in to comment.

Asked:

on 1 Mar 2019

Commented:

on 4 Mar 2019

Community Treasure Hunt

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

Start Hunting!