Sunteți pe pagina 1din 3

ASE 301: Introduction to Computer Programming (Fall, 2015)

Department of Aerospace Engineering and Engineering Mechanics


The University of Texas at Austin
Homework Assignment #1
Due 9 AM Wednesday September 9, 2015
General Guidelines

All the problems include writing a MATLAB code, except the parts that should be done
by hand as labeled.
A well-organized document (either in Word or PDF format) along with all the MATLAB
codes, with your answers to all the problems in order, will be submitted ONLINE via
Canvas. Remember to include your name and UT EID in the document you submit.
Your answer to each problem should include:
a short description of the problem
your approach
the code you wrote
documentation of the results combined all together
Make sure your code works and gives correct results before your submission.
Follow good programming practices and make sure your code is well documented with
comments.

Problem 1 (10 points)


Write a program to calculate
2

607 40
2
(a) 23 8 +
+
+ 4.7

3 8

(b) 5091/3 4.5 2 +

2
ln 200
+ 751/2 e62
1.5

tan ln 8

e 3
6

(c) cos sin 2


+

3
6
8
7 +2
0.02 3.12

( 3tan 27 tan 27 )
(1 3tan 27 )
!

(d)

You are allowed to use appropriate MATLAB built-in mathematics functions.


Submit the source code as hw1_1.m.
ASE 301: Introduction to Computer Programming (Fall, 2015) HW 1

Page 1

Problem 2 (10 points)


Write a program to first define variables a, b, c and d as: a = 18.2, b = 6.42, c = a/b
and d = 0.5(cb + 2a), and then evaluate
(a)

( a + b )c ( a b )c
( a + b )c + ( a b )c

a+b
(b) d
+
c

( a + d )3
a + b + c

(a + b + c + d )
(c) ln ( c d ) ( b a ) +
(a b c d )
b
(d) a c d b +
a
2

1.5

d

c

1/3

+ ebc

You are allowed to use appropriate MATLAB built-in mathematics functions.


Submit the source code as hw1_2.m.

Problem 3 (10 points)


The distance between two points (x1, y1) and (x2, y2) on a Cartesian coordinate plane is given by
the equation
d=

( x1 x2 )2 + ( y1 y2 )2

Write a program to ask the user to input the coordinates of two points (using the input()
function), then calculate the distance between these two points, and output the result using the
disp() function . Using (-3.2, -4.5) and (4.1, -5.9) as your testing example.
Submit the source code as hw1_3.m.

Problem 4 (10 points)


For each of the following pair of MATLAB variable names, identify (by hand) which one is
legal, and give your reason(s) for why the other variable name is illegal:
(a) dog1 and 1dog
(b) 3rd-Component and Third_Component

ASE 301: Introduction to Computer Programming (Fall, 2015) HW 1

Page 2

(c) hard_drive_c and hard_drive.c


(d) whatsup and whats_up
(e) #7 and No_7

Problem 5 (10 points)


Evaluate the following expressions (by hand) without using MATLAB:
(a) (2 ^ (5 * -1 + 3 ^ ((3+1) / 2))) / 4 ^ (18 4 ^ 2)
(b) ~~(35 / 17) == (35 / 17)
(c) 2 + 4 * 3 ~= 60 / 4 - 1
(d) 8 / (2 < 5) * 3 + (1 > 9)
(f) If a = 10 and b = 12, evaluate (a == 9) || (b < 3)
Show your Steps for each question.

Additional Exercises in the Textbook (for practice only, no need to submit)


Exercises: 1.2, 1.4, 2.2, 2.7, 2.10, 3.1
Quiz: 3.1

ASE 301: Introduction to Computer Programming (Fall, 2015) HW 1

Page 3

S-ar putea să vă placă și