1 / 3

RAT 6.1

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).

Download Presentation

RAT 6.1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  3. 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

More Related