finding coordinates from a plot
Show older comments
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
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
Guillaume
on 1 Mar 2019
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.
Guillaume
on 1 Mar 2019
0 votes
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
smile chand
on 2 Mar 2019
Edited: Guillaume
on 4 Mar 2019
Guillaume
on 4 Mar 2019
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.
Categories
Find more on PHY Components 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!