How to plot an equation with two independent and one dependent variable?
Show older comments
p= 0.5 * ∑ ( (-1)^i * (w!/(i!*(w-i)!))*(1-(2*f*i)/w)^k-1)
where ∑ is between i=0 to w, f= w^2/(4*l), l=any prime number greater than 53, k varies between 1 to 100, w varies between 5 to 40.
i want to plot a graph 'k vs p' with w=fixed value eg.w=9
l=53 w=9 f= w^2/(4*l); for k=1:100 for i=0:w temp1=(-1)^i*nchoosek(w,i)*(1-(1-(2*f*i)/w)^k-1); temp(1,i+1)=temp1; end; temp2=0.5 * sum(temp); temp3(1,k)=temp2; end; plot(k,temp3);
though this code is not showing error the plot generated is wrong. the p values must be in the order of 10^-4 to 10^-12 for k ranging from 1 to 100.
Accepted Answer
More Answers (1)
Paul
on 19 Jan 2014
0 votes
it plots only points in vertical line because when you plot k has only a single value, namely 100. Add k=1:100; before the plot command, then it should plot what you want.
Categories
Find more on Mathematics 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!