30 likes | 168 Views
RAT 6.1. Take out a piece of paper, write your name, team#, today’s date and RAT 6.1. You are going to have to write a function file on paper. In the interest of time, you do not have to include any comments. For your homework, however, comments are REQUIRED!. RAT 6.1 (Continued).
E N D
RAT 6.1 • Take out a piece of paper, write your name, team#, today’s date and RAT 6.1. • You are going to have to write a function file on paper. In the interest of time, you do not have to include any comments. For your homework, however, comments are REQUIRED! ENGR 111A
RAT 6.1 (Continued) • In 2-minutes, Individually, write a function file to compute the area of a square given the dimension of a side. You will receive BONUS points if the function also outputs the perimeter. Test your algorithm using hand calculations for a square with side dimension of 4. • Within 30-seconds submit your papers to your GANT or Peer Teacher. ENGR 111A
RAT 6.1 Solution function [area_square, perimeter] = square(side) % % function [area_square, perimeter] = square(side) % % This function computes the area and perimeter of a square. % % INPUTS: % side = The length of one side of the square (units) % % OUTPUTS: % area_square = The area of the square (square units) % perimeter = The perimeter of the square (units) % % This is the solution to RAT 6.1 % % S. Socolofsky % ENGR 111A: 501-503 % October 2004 % % Compute the values of the output variables area_square = side.^2; % Area of a square perimeter = 4.*side; % Perimeter of a square ENGR 111A