Could you help me modify this MATLAB function so that it assigns random birthdays to people in an increasingly large gro

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Could you help me modify this MATLAB function so that it assigns random birthdays to people in an increasingly large gro

Post by answerhappygod »

Could you help me modify this MATLAB function so that it assigns
random birthdays to people in
an increasingly large group of people (starting with a group size
of 2 people and ending
with a group size of 365) and also generate whole numbers from 1 to
365 to represent each day. rather than the day/month format.
function dates = Myfunction(n)

dates=[];

for count = 1:n

random_month = randi([1 12], 1,1); % generate a random month 1 to
12
month = random_month(1,1);
if (month == 4 || month == 6 || month==9 || month==11 )
day = randi([1 30], 1,1); % there are 30 days
else if month==2
day = randi([1 28], 1,1); % there are 28 days
else
day = randi([1 31], 1,1); % there are 31 days
end
dates = [dates; [month,day]];

end

end
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply