MATLAB CODE:
% Perform housekeeping clear; clc; clf; % Number of coins n = 100; % Generate random variables x, y x = rand(1, n); y = rand(1, n); % Scatter plot plot(x, y, 'o'); title('Location of Simulated Coins in Unit Square'); xlabel('x position'); ylabel('y position'); hold on; % Inscribe a quarter circle x^2 + y^2 = 1 theta = linspace(0, pi/2); % Draw circle using x = r*cos(theta) and y = r*sin(theta) xx = cos(theta);% Here r = 1 yy = sin(theta);% Here r = 1 plot(xx, yy); hold off; % Vector of distance of each coin to the origin r = sqrt(x.^2 + y.^2); % Count number of coins inside the quarter circle insideCount = length(find(r < 1)); % Ratio of the number of coins inside the quarter circle to the total % number of coins ratio = insideCount/n; % Associate Pi with 4 * The Ratio of the Number of Coins inside the quarter % circle to the total number of coins result = pi*4*ratio;
SAMPLE PLOT:
FOR ANY HELP JUST DROP A COMMENT
need help with matLab Question 1 (20 Points) Write a well-documented MATLAB script hmwk7Q1.m that simulates...