Plotting a 2 dimensional graph
Mostra commenti meno recenti
Function: S(p,N) = 1 - (1-p)^N
Plot a two-dimensional surface showing that probability: S(p,N), 0p1,2N10,000.
8 Commenti
Geoff Hayes
il 18 Feb 2020
Spencer - If this is homework, what have you tried so far?
Spencer S
il 18 Feb 2020
Geoff Hayes
il 18 Feb 2020
Modificato: Geoff Hayes
il 18 Feb 2020
Are p and N inputs or outputs of this function? Please see Declare function name, inputs, and outputs for an idea of how to set the signature for your function.
Spencer S
il 18 Feb 2020
Geoff Hayes
il 18 Feb 2020
Does p just take on the values of 0 and 1 or are you interested in others? Consider meshgrid to create some data for your probability function.
Spencer S
il 18 Feb 2020
Spencer S
il 19 Feb 2020
Geoff Hayes
il 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.
Risposte (1)
Aquatris
il 18 Feb 2020
0 voti
What you are looking for is the "countour" function (or countourf) of Matlab. Check this link and you can adapty your equation to the given example.
Categorie
Scopri di più su Line Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!