Which solver do I use to determine how many pairs of (X,Y) satisfy the inequality x^2 + y^2 < 1 ?
2 views (last 30 days)
Show older comments
If I have a set of 1000 generated random numbers (X) and another set of 1000 generation random numbers (Y), which solver do I use to determine how many pairs of (X,Y) satisfy the inequality x^2 + y^2 < 1 ?
0 Comments
Answers (2)
Azzi Abdelmalek
on 4 Oct 2013
n=numel(x)
[ii,jj]=ndgrid(1:n,1:n);
z=x(ii(:)).^2+y(jj(:)).^2;
idx=find(z<1)
sols=[x(ii(idx))' y(jj(idx))']
See Also
Categories
Find more on Mathematics and Optimization 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!