1

I want a specific value in the figure in MATLAB. I put the black circle and arrow manually through the figure insert option. But How can I set the value now? I want the x-axes values that are exactly 90% of each CDF curve. here I am attaching my MatLab figure in jpg mode.

Image of CDF

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • Please see `scatter` or `plot` for circle and [How to Draw an Arrow?](https://stackoverflow.com/questions/25729784/how-to-draw-an-arrow-in-matlab) for arrow – Sardar Usama Dec 26 '19 at 11:18

3 Answers3

2

I would use interp1 to find the value. I'll assume that your x variable is called x and your cdf value is called c. You can then use code like this to get the x value where c = 0.9. This will work even if you don't have a cdf value at exactly 0.9

x_at_0p9 = interp1(c, x, 0.9);
Kenneth Boyd
  • 667
  • 2
  • 6
1

You plotted those figures by using:

plot(X,Y)

So, your problem is to find x_0 value that makes Y = 0.9. You can do this:

ii = (Y==0.9) % finding index
x_0 = X(ii) % using index to get x_0 value

Of course this will only work if your Y vector has exactly the 0.9 value.

As this is not always the case you may want to get the x_0 value that first makes Y to be greater or equal than 0.9.

Then you can do this:

ii = find(Y>=0.9, 1) % finding index
x_0 = X(ii) % using index to get x_0 value
Ita
  • 303
  • 5
  • 17
0

Assuming that your values are x and Y (where x is a vector and the same for all curves) and Y is a matrix with the same number of rows and as many columns as there are curves; you just need to find the first point where Y exceeds 0.9:

x = (0:0.01:pi/2)'; % time vector
Y = sin(x*rand(1,3))*10; % value matrix

% where does the values exceed 90%?
lg = Y>= 0.9;

% allocate memory
XY = NaN(2,size(Y,2));

for i = 1:size(Y,2)
    % find first entry of a column, which is 1 | this is an index
    idx = find(lg(:,i),1);

    XY(:,i) = [x(idx);Y(idx,i)];
end

plot(x,Y, XY(1,:),XY(2,:), 'o')
max
  • 3,915
  • 2
  • 9
  • 25
  • Thank you but Sorry, I want the value itself, not the circle only. – Tania islam Dec 27 '19 at 02:11
  • @Taniaislam can you share your code of calculating CDF and plotting the figure and datasets ? so I can modify that for you to get the value of 90% if you want. – Bilal Dec 27 '19 at 09:59
  • @Taniaislam, you find the value in `Y(idx,i)` because you need the values to plot the circles;) – max Dec 27 '19 at 15:09
  • @BelalHomaidan yes, Here is my script. Actually I extract my original dataset to simplify the problem. Can you please help me to plot of point and string on the figure. – Tania islam Dec 29 '19 at 05:49
  • Sorry, I cannot attach the file. How can I attach the script? – Tania islam Dec 29 '19 at 05:54
  • @Tania-islam you can modify the original question, and add your code and necessary links of GitHub to the original question – Bilal Dec 29 '19 at 08:51