Results 1 to 2 of 2

Math Help - Matlab - Fuctions/Scripts

  1. #1
    Newbie
    Joined
    Jan 2010
    Posts
    1

    Matlab - Fuctions/Scripts

    So basically I have to edit this code so that I can find the probability of the points falling within a circle of
    radius 0.5 centered at (0.5, 0.5). I then need to run it for 1000 points!!!I'm really new to matlab and can't figure it out.

    Code:
    N = 100;
    figure(1);
    clf;
    point = rand([2 N]);
    plot(point(1,:), point(2,:), 'xb');
    xlim([0 1]);
    ylim([0 1]);
    
    hold on;
    count = 0;
    for i=1:N
        if (point(1, i) < 0.5) && (point(2,i) < 0.5)
            plot(point(1,i), point(2,i), 'xr')
            count = count + 1;
        end
    end
    
    probability = count / N;
    title(strcat('Probability is:', num2str(probability)));
    Last edited by exzacklyright; January 14th 2010 at 10:38 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor

    Joined
    Aug 2008
    From
    Paris, France
    Posts
    1,174
    Quote Originally Posted by exzacklyright View Post
    So basically I have to edit this code so that I can find the probability of the points falling within a circle of
    radius 0.5 centered at (0.5, 0.5). I then need to run it for 1000 points!!!I'm really new to matlab and can't figure it out.
    Little change is necessary. Do you understand what your code already does? (You should try to run it)
    A question you should consider is: given two coordinates x,y, how can you check (by a formula) whether the point (x,y) is in the circle you describe?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Inverse Of Fuctions
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: September 20th 2009, 04:48 PM
  2. Exponential Fuctions
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: December 10th 2007, 01:06 PM
  3. Replies: 7
    Last Post: October 17th 2007, 10:22 PM
  4. Probability Distribution Fuctions....
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: October 16th 2007, 06:58 PM
  5. Probability Distribution Fuctions....
    Posted in the Statistics Forum
    Replies: 0
    Last Post: October 16th 2007, 06:55 PM

Search Tags


/mathhelpforum @mathhelpforum