why is my results coiming out as a single 0 while using matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
oshomah kanoba
am 1 Mär. 2015
Beantwortet: Mischa Kim
am 1 Mär. 2015
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 Kommentare
Akzeptierte Antwort
Mischa Kim
am 1 Mär. 2015
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Verify Generated Code and Deployed Code Artifacts finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!