Unit 11 Test

# Unit 11 Test - UNIT11TEST 1. (i.e.11235813etc.Writeyour...

This preview shows pages 1–3. Sign up to view the full content.

UNIT 11 TEST 1. Create a vector using a FOR loop that populates the first 12 elements of a  vector with values of the Fibonacci Series (i.e. 1 1 2 3 5 8 13 etc.]. Write your  code in an m-file and turn in the code. fibf(1) = 1; fibf(2) = 1; for n = 3:1:12 fibf(n) = fibf(n-1)+fibf(n-2); end >> fibf(1:12) ans = 1 1 2 3 5 8 13 21 34 55 89 144 2. Write a function in MATLAB called myResult that takes one argument x and  returns the result of the equation tan(x)*sin(x). The argument x can be a scalar  or a vector. If it is a vector, the equation should be solved for each element  and return a vector with the results. % CODE function [result] = myResult(x)  result = tan(x).*sin(x) %SINGLE NUMBER (SCALAR) myResult (60) result = -0.0976

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
%VECTOR a = [30 60 90 120 150 180] a = 30 60 90 120 150 180 >> myResult (a) result = 6.3287 -0.0976 -1.7837 0.4140 0.7309 -1.0725
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/02/2011 for the course ME 205 taught by Professor Koen during the Spring '07 term at University of Texas.

### Page1 / 3

Unit 11 Test - UNIT11TEST 1. (i.e.11235813etc.Writeyour...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online