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
Could you help me modify this MATLAB function so that it assigns random birthdays to people in an increasingly large gro
-
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!