Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
1A) Script:
v=textread('code_letters.txt',''); %inputs a file, breaks it up at every
space, and names it with the variable v.
m=length(v); %this is finding the length of v, or how many words are in v and
setting equal to m.
s=0; ets the letter s equal to
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
Ali Rajab
BE1500
While Loops
A while loop will continue to be repeated until some condition is satisfied.
Example: Consider an amount of money deposited in an interestbearing account. If we want to
determine how long it will take until the account reache
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
> clear
A = 2;
while A < 10
A = 2*A;
end
A
A=
16
%Exercise_2
A = 2;
i=0
while A < 10
i=i+1;
A = 2*A;
end
A
i
i =
0
A =
16
i =
3
%Exercise_3_a
i=0;
A= 2;
while A <= 32
i=i+1;
A = 2*A;
end
A
A =
64
%Exercise_3_b
i=0;
A= 2;
while A <= 32
i=i+1;
A = 2*A;
End
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
Matrix Element Search
function matrixElementSearch(elementSearch, matrixTest)
%MatrixElementSearch.m: Function that searches for an element
%'elementSearch', in the inputted matrix, 'matrixTest'.
[numOfRows numOfCols] = size(matrixTest);
storeElementIndic
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 4 and 5 Exercises
1. Plot the following time and acceleration data on one graph. Remember to include a title, axes
labels, and a properly labeled legend. Model a1 as a solid red line, a2 as a dashed green line, a3
as black circles, and a4
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500:091 Homework 2
Copy and paste your MATLAB commands and final answers into a Word document for each problem.
Upload the assignment to Blackboard by September 19th before class.
1. Use MATLAB to calculate the following values; use format short:
1
a.
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500091 Homework 4
Submit a zipped folder (compressed folder) containing .m files for each of the following problems. The
folder should be named with the format accessID_BE1500_HW4. Remember, if your .m file is a function
file, then you must keep the
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 3 Exercises
1. Without typing the following commands into MATLAB, determine what the output would be. Then
check your answers.
a. >a=1:2:9
b. >b=13:2:28
c. >c=linspace(13,28,8)
d. >d=linspace(7,63,14)
e. >g=linspace(10,0,6)
f. >h=3:1:10
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
%Exercise_1a
format short
a = 4*5*cos(pi/3)(log(1.24)^(1/3)*tan(pi/3)
%Exercise_1b
b = (2*tand(30)^2)/15)(log10(14)*(exp(1/8)/12)(25/
(12+sind(30)
%Exercise_2
format long
c1 = 17^(1/2)
c2 = sqrt(17)
c3= 17^.5
Exercise_3
format short e
%3a
p1 = cosd(45)
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 2, Exercises
1. Type the following equation into MATLAB:
=
2
6 19
4 + 5
3
7 11
2. The following equation is typed into MATLAB:
= 3
25 16
3
+
7 22
3
19
13
The following are two MATLAB commands used to represent this equation. Do they
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500091 Homework 3
1. Plot the following data. Remember, two plots on the same graph need to be represented differently
(suggestions are given below); you need a graph title, axes labels, and a properly labeled legend.
Time (s) = 0 10 20 30 40 50
V1 (
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
Lecture 7 Exercises Using Function Files and Scripts
1. The figure below is a diagram of the cross section of an irrigation channel. The crosssectional area of the channel should be 100 ft2 to carry the desired water flow rate. Our
task is to minimize the
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Lecture 4 Exercises
1. Plot the following time and acceleration data on one graph. Remember to include a title, axes
labels, and a properly labeled legend. Model a1 as a solid red line, a2 as a dashed green line, a3
as black circles, and a4 as blu
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500091 Homework #5
Zip your submission files into a compressed folder. Your folder should contain the necessary
script files (.m files) and figure files as (.jpg) file types to answer the questions for the homework
set. Label your folder as your acce
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
Tannia Rodriguez
BE 1500
October 31st, 2013
%SOF
function maxSubsequence(arrayInput)
maxArray=zeros(1, length(arrayInput);
currMax= realmax;
for i= 1:length(arrayInput)
for j=i:length(arrayInput)
array=[];
arrayz=0;
for k = i:j
arrayz= arrayz+1;
array(ar
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
Tannia Rodriguez
BE 1500
October 31st, 2013
%SOF
function maxSubsequence(arrayInput)
maxArray=zeros(1, length(arrayInput);
currMax= realmax;
for i= 1:length(arrayInput)
for j=i:length(arrayInput)
array=[];
arrayz=0;
for k = i:j
arrayz= arrayz+1;
array(ar
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
BE 1500 Fall 2016
Quiz 5
1. Write a script that produces the following output. The script should iterate from 1 to 9 to
produce the expressions on the left, perform the operation to get the results shown on the right,
and print the output below. Your code
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
1. The nth Fibonacci number is defined by the following recursive equations:
f(1) = 1
f(2) = 2
f(n) = f(n1) + f(n2)
Therefore, f(3)=f(2)+f(1)=2+1=3, and so forth for higher numbers. Write a function file to
calculate and write out the nth Fibonacci numb
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Fall 2016
HW 5
Due: October 13, 2016 (1:30 P.M.)
1. Write a code for repmat; the only builtin commands you are allowed to use are input, size, and
disp.
A=input('matrix ');
[m,n]=size(A);
z=input('replicated rows ');
y=input('replicated columns '
Introduction to Programming and Computation for Engineers
BE 1500

Fall 2013
BE 1500 Homework 8
1. Write a script that determines the following sum (for all odd n from 3 to 13) using a for loop:
2+2
=
1
2. The nth Fibonacci number is defined by the following recursive equations:
f(1) = 0; f(2) = 1; f(n) = f(n1) + f(n2)
Theref
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  Fall 2017  Final Project
Big Data is a common buzz word thrown around in the world today. While not truly working with Big
Data, this project will give you a chance to get an idea of how that data is used.
Big data involves the analysis of exce
Introduction to Programming and Computation for Engineers
BE 1500

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

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

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

Fall 2013
BE 1500 Quiz 5  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 files that the assignment