dvide 500 random color to 80 different basket
Show older comments
hey
im trying to make a code that recive 500 ball ( 100 of each color : red blue yellow green purple)
then i want matlab will dvide this 500 ball randomly to 80 different basket
i have tryd few command and loops without succses
here is my code so far
%%
clear all
clc
for i=1:100
%deck(i,:) =( ["1","2","3","4","5"]' ); test
deck(i,:) =( ["R","G","P","Y","B"]' );
i=i+5;
end
n=0; % counter
%r=randi([1,80],1,500);
for i=1:500
temp=(randi([1,80]));
n=n+1;
K(n,:)=temp;
end
% not sure if nessacery
A=zeros (500,80);
B=zeros (500,80);
%dvide the 500 ball to 80 basket
for i=1:500
temp=deck(i);
tempb=K(i);
A(tempb,:)=temp;
B(:,tempb)=temp;
C(:,K(i))=deck(i);
D(K(i,:))=deck(i);
%F=struct(tempb,temp);
%data.K(i,:)=deck(i);
%data(K(i,:)).tempb=deck(i);
random(K(i,:)).tempb=deck(i);
end
i will appriciate any help to solve this problem
Accepted Answer
More Answers (1)
KSSV
on 4 May 2021
N = 100 ;
R = ones(N,1) ;
B = 2*ones(N,1) ;
Y = 3*ones(N,1) ;
G = 4*ones(N,1) ;
P = 5*ones(N,1) ;
balls = [R; B; Y; G; P] ;
% randomise the order
balls = balls(randperm(length(balls)))
% choose any 80 balls out of it
iwant = balls(randperm(length(balls),80))
4 Comments
shalom kobi
on 4 May 2021
Edited: shalom kobi
on 4 May 2021
KSSV
on 4 May 2021
You already know what should be there in each basket...... what is there to solve now and code?
shalom kobi
on 4 May 2021
shalom kobi
on 4 May 2021
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!