Problem 1: Write a function in MATLAB that fits randomly chosen circular disks of various radii with centers at random locations within a box of dimensions: length = L and height = H.
Disk radii are integers randomly chosen from {1, 2, 3, ..., max_rad} where max_rad is a user-defined parameter. Disk centers are randomly located at integer coordinates within the box. None of the disks should overlap. All disks should be contained within the boundary of the box.
You can assign different colors to disks with different radii when plotting the results.
Your function should try to fit as many disks as possible within the domain: L x H. The best code will be able to fit the most number of disks. Your function should plot the disks and should return the data, i.e. radii and centers, of the plotted disks. You can use the MATLAB function randi() to generate random numbers. For example, xc = randi(L) will give a random integer between 1 and L; yc = randi(H) will give a random integer between 1 and H; rad = randi(max_rad) will give a random integer between 1 and max_rad. Try to make your function as robust as possible. Test various cases!
function [radii, centers] = fit_disks(L, H, max_rad, max_num) % Inputs % L -> Length of box % H -> Height of box % max_rad -> maximum radius of disk
% Note: Your function might not be able to fit the max_num specified. The goal is to fit as many disks as possible. You need to build some reasonable logic to accomplish this task. % You can add more inputs/outputs if necessary end