Briana Smith
PHYS108 Exam 01
QUESTION 2. Write a short function to determine the second largest
element for an input vector, x.
function sec_largest(x)
sorted_vec = sort(x);
sec = sorted_vec(length(so
PHYS108 HW_04 String Manipulation
1) Create a function, termed random_lower_letter, which returns a random lower letter of
alphabet.
function letIn = random_lower_letter
letIn = char(randi([97 122], 1
PHYS_108 Exam 2
QUESTION 1
function month(length, start)
day = 1;
count = start;
weeks = cell(5,7);
%populate the first week at the appropriate start day
for a = 1:7-start+1
weeks(1, count:end) = cfw_
PHYS108 HW_06
1) Read a text file, random_integers.txt, that contains a list of ten integers of arbitrary
size, stored
one integer per line. Write a function to read this list and write it to a second
PHYS108_HW05
1) Create a function that will generate two random integers in the range 10 to 99. It will return a string
consisting of the two integers joined together. (e.g., if the random integers ar
PHYS108 hw_02 MATLAB Expressions and Matrix Manipulation
1) Work out the results of the following expressions:
a = [-1 0 3]; b = [0 3 1];
a. ~a
b. a & b
c. a | b
d. a > 0 & b > 0
e. a > 0 | b > 0
f. ~
PHYS108 Home Work 1
DUE: Monday 09/23/2013 at 5 PM.
You may want to use the d iary command to create the homework. If you do so, you must edit your diary
output to remove any errors!
1.
2.
Evaluate th
9/23/13
phys108_hw01
%
cfw_
BIN SIH
RAA MT
PY18H 0
HS0 W 1
%
%USIN1
QETO
1+2*3
%utocr frt
ml cus is
as=
n
7
(./.)2 %iiinwti teprnhssfrtte epnn
2030^
dvso ihn h aetee is hn xoet
as=
n
044
.44
%
cfw_
m
Vectors and Number Manipulation
PHYS108 HW_03
1) Create the following variable:
x = 12.34;
y = 4.56;
Then ll in the fprintf using these variables to accomplish the following:
> fprintf(
x is 12.340
>