unable to get desired results
Ältere Kommentare anzeigen
Please find the below code.
User = zeros(1,10);
for i = 1:10
probability_of_transmission = rand(1);
if probability_of_transmission > p
j = 5;
User(i) = 1;
else
User(i) = 0;
end
end
I just want the output to be somewhat like: User = [ 0 0 0 1 1 1 1 1 0 0 ]. How can i put one more if argument in the for loop so that at the end i will get consecutive ones insetead of ones at random index.
4 Kommentare
Torsten
am 13 Jul. 2022
What is the task behind the creation of the vector "User" ?
Prashant Bhagat
am 13 Jul. 2022
Abderrahim. B
am 13 Jul. 2022
and what does that j doing there in your loop ? With using rand to compute probability_of_transmission you can't get the User vector you want.
Prashant Bhagat
am 13 Jul. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!