How can we randomly assign the number we want to the machines that write 1 in the 1-0 matrix?
2 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I need your help, We're solving a genetic algortihm questions. We have created a chromosome structure that assigns the numbers as 1-18. (9*138) We want to assign a random value between 1-10 to the numbers 1 in the 1-0 matrix we have created now. How can we code this in matlab?
Our code that we use;
for b = 2:9
N = 138;
j=1;
for i = 1:2:N
population(1,i) = int32(j);
population(b,i) = randi([1 10],1);
population(1,i+1) = int32(j);
population(b,i+1) = randi([11 18],1);
j = j+1;
end
end
Thanks in advance.
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!