How can I get correct M array?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
My code as below. The output of M is all zeros. How could I get correct M array?
K=100;
for k=1:K
S=zeros(1,k);
A=zeros(1,10);
M=zeros(1,K);
for N=1:k
for i=1:1:10
u=rand(1);
if u<=0.15
x=1;
else
x=0;
end
A(i)=[x];
end
X=sum(A);
S(N)=[X]
m=mean(S)
end
M(k)=[m]
end
댓글 수: 0
답변 (1개)
KSSV
2020년 9월 8일
Wont this simply work for you?
K=100;
X = rand(K) ;
x = X<=0.15 ;
m = mean(x) ;
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!