why is my results coiming out as a single 0 while using matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
R = rand (10,1)% generate a sample in Unif(0,1) P = 0.5 N = 10 if R < P fprintf = 1 else fprintf = 0 end
댓글 수: 0
채택된 답변
Mischa Kim
2015년 3월 1일
R is a vector, P is a scalar. Do you mean to do
R = rand (10,1)% generate a sample in Unif(0,1)
P = 0.5; N = 10;
for ii = 1:numel(R)
if R(ii) < P
fprintf = 1
else
fprintf = 0
end
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Verify Generated Code and Deployed Code Artifacts에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!