Need to make a matlab program that estimates the area of circle (w/o pi*r^2) and
ID: 3559328 • Letter: N
Question
Need to make a matlab program that estimates the area of circle (w/o pi*r^2) and find the error. Has to follow these conditions:
1.Use lower/upper bounds for area (think of triangles).
2. A person should be able to put in diam. of circle and relat. error.
3. Program runs till estimated error is under defined error.
4. The final output is the area of a circle and the error.
5. Code has to follow as so:
-while 1 infinite loop
-Inside while loop, must be area calculations, then determine the error (half the distance btwn upper and lower bound). Now normalize the error by your area estimate, using the average of the upper and lower bounds as your estimate.
-Next is break condition. This will be an if statement where you check if your current error is less than your desired error. If so, you would break. End the if statement. Increment counter. Close while loop. -Display output.
Pls email at klfond45@gmail.com for more specific details. Thank you
Explanation / Answer
diameter= inputdlg('Enter diameter','s');
waitfor(diameter);
diameter=diameter{1};
diameter=str2num(diameter);
relError= inputdlg('Enter relError','s');
waitfor(relError);
relError=relError{1};
relError=str2num(relError);
N=5;
upperBoundArea=0;
lowerBoundArea=0;
errorOccur=0;
area=0;
while(1==1)
upperBoundArea=N*((diameter/2)^2)*tand(180/N);
lowerBoundArea=N*((diameter/2)^2)*cosd(180/N)*sind(180/N);
errorOccur=(upperBoundArea-lowerBoundArea)/2;
area=(upperBoundArea+lowerBoundArea)/2;
if (errorOccur<=relError)
break;
end
N=N+1;
end
display(area);
display(errorOccur);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.