Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi guys, I need help with matlab. I took a pic of the qustion. I have done must

ID: 3622928 • Letter: H

Question

hi guys, I need help with matlab. I took a pic of the qustion. I have done must of the qustion. I made matlab plote the points but I still cant make it make the circle & make the points only inside it 2 approximate pi

 

 

here is my code that I made, I just make it do the square plot but still I couldn't make the circle:

% Random Points

a = input('Enter number of points: ');

x=rand(1,a);

y=rand(1,a); 

%Equation of Circle(r=1): x^2+y^2=1

if (x.^2+y.^2)<=1

plot(x,y,'+k')

else

plot(x,y,'+r')

end

Explanation / Answer

% Random Points

a = input('Enter number of points: ');

x=rand(1,a);

y=rand(1,a);

count =0;

%Equation of Circle(r=1): x^2+y^2=1

if (x.^2+y.^2)<=1

plot(x,y,'+k')

else

plot(x,y,'+r')

end

for i=1:a

if(x[i]*x[i] + y[i]*y[i]) <= 1

count++;

end

end