25 views (last 30 days)

Show older comments

Function: S(p,N) = 1 - (1-p)^N

Plot a two-dimensional surface showing that probability: S(p,N), 0p1,2N10,000.

Geoff Hayes
on 19 Feb 2020

Right but you still need to define what those values are for p. Is it sufficient to do something like

p = 0:0.01:1;

where the array p is all values 0, 0.01, 0.02, 0.03,..., 1.0? Or do you need more or fewer? Once you have determined that and done something similar for N (this is probably easier and you could use your code above), then you can use meshgrid as

[P,N] = meshgrid(0:0.01:1, 2:1:10000);

and then put those results in your above function. Then try using contour that Aquatris described below.

Aquatris
on 18 Feb 2020

Aquatris
on 20 Feb 2020

Dont exactly know your values but something like this;

p = linspace(0,1,1e3);

N = linspace(2,1000,1e3);

[X,Y] = meshgrid(p,N);

Z = 1-(1-X).^Y; % notice the .^ since we do not want matrix algebra

contourf(X,Y,Z)

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

Start Hunting!