Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
IN CLASS EXAM REVIEW QUESTIONS:
1. Write a function file named circles that will calculate the circumference and area of five
circles. The function should have five input arguments (each a diameter) and display the
results in 3 columns with the following
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
HW 4
Due: 9/29/16 (1:30 P.M.)
1. Write a function file that determines the following sum (for all odd n from 1 to 11) using a for
loop. The starting point, ending point, and increment should be input to the function file.
y=
2n+ 2
n2
2.
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
Homework 3
Due: Thursday, September 22, 2016
Convert the following from decimal to binary.
1.
2.
3.
4.
5.
6.
7.
57
119
1120
11657
7/8
0.68
103.77
Convert the following from binary to decimal.
8. 1001
9. 1100111
10. 111111000011100
Conver
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
Quiz 3
1. The distance equation for threedimensional space is given below. Write a function file that
accepts the equation (defined as an anonymous function) and accepts (x,y,z) coordinates for two
different points (you will have 7 inpu
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
Homework 2
Due: 9/15/16 (by 1:30 P.M.)
1.
Generate the following matrix without typing in each individual element. Utilize the colon
operator, linspace, and other builtin MATLAB functions.
4 9 14
0 0 0
10 7 4
Using this matrix as a star
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
HW 2 Solutions
1. > A=[4:5:14;zeros(1,3);10:3:4]
> B=flipud(A)
> C=rot90(B)
> C(1,1)=12;C(2,2)=5;C(2,3)=0;C(3,2)=3
> D=repmat(C,2,3)
0.5 (Their answers dont have to match this; give them credit if they at least attempted the
problem and
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework #6
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word
document. For excel portions, copy the contents of any calculated cells into the document with
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework #5
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word
document. For excel portions, copy the contents of any calculated cells into the document with
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework 6 Solutions
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word
document. For excel portions, copy the contents of any calculated cells into the docu
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework 2  SOLUTIONS
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word document. For
excel portions, copy the contents of any calculated cells into the do
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework #3
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word document. For
excel portions, copy the contents of any calculated cells into the document with
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework #7
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word
document. For excel portions, copy the contents of any calculated cells into the document with
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework #4
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word
document. For excel portions, copy the contents of any calculated cells into the document with
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
Homework 1
Solutions
1.
Solution
> format short
> a=4*5*cos(pi/3)(log(1.24)^(1/3)*tan(pi/3)
a = 8.9622
1/2
2. Solution
> b=(2*tand(30)^2/15log10(14)*exp(1/8)/1225/(12+sind(30)
b = 2.0193
1/2
3. Solution
> format long
> c=17^(1/2)
c =
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE1500
Lecture 9
for Loops
The for Loop in MATLAB
a. for Loop Example
b. for Loop in Interactive Mode
c. for Loop Example
d. for Loop Example
e. for Loop Example
1. Write a script (that includes a loop) to calculate each of the following finite sums. Run
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 15
Integrals, Derivatives,
Differential Equations
Professor Tonya Whitehead
Numerical Calculus
Numerical Integration
fun = Anonymous Function
xmin = minimum value of the integration
xmax = maximum value of the integration
Example:
fun
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 8
Binary
Professor Tonya Whitehead
Todays Class
Discussions
Review Polling
What is Binary
Converting whole numbers Binary to Decimal & Decimal to
Binary
Converting fractional numbers Binary to Decimal & Decimal to
Binary
IEEE 754 Flo
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 2
Review: Trig, Exp, Long Division
New Topic: Matrix Manipulation
Professor Tonya Whitehead
Overview
Long Division
Exponents / Logs
Trig Functions
Creating Matrices
Matrix Manipulations
Matrix Math
REMINDER: Use Diary
Saves everythi
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 9 Part 2
1. Write a script (that includes a while loop) to calculate each of the following finite sums. The
script should end when the value either equal or exceeds M. Have the script display the number
of values added and the total sum:
a
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
For Loop
Examples
1. for ii = 1:10
end
ii
%ii goes from 1 to 10
2. a = 5:5;
for ii = 1:length(a)
a(ii)
end
%ans goes from 5 to 5
3. %We want to sum up the elements of the vector a
a = 1:10;
sum_a = 0;
for ii = 1:length(a) %We want to go through each of
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 9
For & While Loops
Professor Tonya Whitehead
Overview
Review Binary
Debugging Tools
Introduction to Loops
For
While
Poll Question 1
What is the binary representation of 12?
A. 01110
B. 00110
C. 10101
D. 01100
E. 10000
Poll Question 2
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 3
Anonymous Functions,
Plotting
Professor Tonya Whitehead
Overview
Basic Plotting
Multiple Plots
Changing Colors and Lines
Adding Titles and Axis Labels
Using Subplot
Adjusting Axes
Anonymous Functions
Using fplot
Basic Plotting
S
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
Lecture 3
1. Create a vector from 1 to 10. Create 3 more vectors by plugging your first vector into the
following 3 equations:
a= 1:10
a=1
2
3
4
5
6
7
8
9 10
> f1=@(x)3*x.^2+5
f1 = @(x)3*x.^2+5
> f2=@(x)12*x5*x.^2
f2 = @(x)12*x5*x.^2
> f3=@(x)x.^3+2*x.^
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Winter 2016
Quiz 4
Due: 3/2/16
Convert the following from decimal to binary.
1.
133
2.
0.36
Convert the following from binary to decimal.
3.
10010111
4.
0.11011
Convert the following from decimal to IEEE double precision floating point format. Ind
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Winter 2016
Extra Credit Assignment
Due: 3/23/2016 (12:30 P.M.)
1. Write your own code to perform matrix multiplication. Recall that to multiply two matrices, the
inner dimensions must be the same.
[A]mn[B]np = [C]mp
Every element in the resulting
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Quiz 3  Solution
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word document. For
excel portions, copy the contents of any calculated cells into the documen
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Quiz 1  Solutions
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word document. For
excel portions, copy the contents of any calculated cells into the docume
Introduction to Programming and Computation for Engineers
BE 1500

Spring 2013
/*
A car dealer has 10 salespersons. Each salesperson keeps track of the number of
cars sold each month
and reports it to the management at the end of the month. The management keeps
the data in a file and assigns a number,
1 to 10 to each salesperson. Th
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework 9
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word
document. In addition to the PDF submission submit any script files that the assignment asks yo
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Quiz 7  Solutions
Submit this assignment as a PDF to the link on Blackboard
Copy and paste your MATLAB commands and final answers for each problem into a word document. In
addition to the PDF submission submit any script or function files that th
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Quiz 6  Solutions
1. Convert the following from decimal to binary SHOW YOUR WORK!
237.93359375 > 11101101.11101111
2. Convert the following from binary to decimal SHOW YOUR WORK!
11000000111001.00111 > 12345.21875
3. Factor the following equati
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework 8  SOLUTIONS
1. Write a script that determines the following sum (for all odd n from 3 to 13) using a for loop:
2+2
=
1
y = 0;
for n = 3:2:13
y = y + (2^(n+2)/(n1);
end
display(y)
> F16_HW8_1
y=
3.9392e+03
2. The nth Fibonacci number
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
Exam 1 Study Guide
Topics to study:
Vector manipulation
o Ones
o Zeros
o Linspace
o Colon operator
o Dot operator
Matrix manipulation
o Fliplr
o Flipud
o Rot90
o Repmat
Plotting
o Plot
o Subplot
o Fplot
Anonymous Functions
Scripts
Functi