Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: help with assigment
Date: Fri, 24 Jun 2011 20:40:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 37
Message-ID: <iu2sn5$ejl$1@newscl01ah.mathworks.com>
References: <iu2plk$55e$1@newscl01ah.mathworks.com> <iu2r2l$9nn$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1308948005 14965 172.30.248.38 (24 Jun 2011 20:40:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 24 Jun 2011 20:40:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2928084
Xref: news.mathworks.com comp.soft-sys.matlab:733628

these are the codes i wrote for question 1
For question 1

n=1000;
m=10000;


T=100;

for k=1:m
    
    P=0;
    X=ceil(6*rand(1,n));
    Y=ceil(6*rand(1,n));
    
for j=1:n
        if X(j)+Y(j) == 7;
            P=P+1;
        end
    end
    
    disp('Trial: ')
    k;
    disp('Success Rate: ')
    P=P/n;
    
    Xaxis(k) = k;
    Yaxis(k) = P;
    T=T+P;
end

disp('Total Average: ')
T/m;

plot(Xaxis,Yaxis);

clear;