Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

LAB SUMMARY

EXERCISE ONE
This exercise began with the introduction of how the values of
some constant variables are reserved in the program. Pi=3.1416,
eps=2.2204e-16, realmax=1.7977e+308 and realmin=2.2251e-
308.
Matlab displays some of the values in a more precise way than
others. In this case ‘b’ is displayed in a more precise way than
‘a’. And for the values of ‘a’ and ‘c’, I think they are the same in
format. Format long cause b to be printed in a more precise way.
Matlab measures the angles in radians. a1= ‘sqrt(4)’ means the
string sqrt(4) should be assigned to a1 while sqrt(4) means 2
should be assigned to a2.eval(a1) yields the result 2. And
a3=5*eval(a1) produces 10.
EXERCISE TWO
This exercise focused on variables being treated as matrices in
matlab. The expression meshPoints(53) yields the 53rd element
which is -0.477386934673367. After creating the .m file with
the same commands, the same thing appeared even without the
comment.
EXERCISE THREE
This exercise involves matrix and vectors manipulations. I don’t
understand why the first values of colVec2 be overwritten. I was
not expecting those values. But I didn’t see any error message
when I added colVec1 and rowVec1. Also one main thing that
interest me here is the easiness in transposing a matrix. The
matrix A is a magic matrix with row sums and diagonal sums
equal to 500050. To extract the matrix,
 upper left quarter=A(1:5,1:5).
 Upper right quarter=A(1:5,6:10).
 Lower left quarter=A(6:10,1:5)
 Lower right quarter=A(6:10,6:10)
EXERCISE FOUR
This exercise talks about flow control in terms of
performing repetitive calculations. This involves the ‘for’
and ‘while’ loops and also the ‘if’ construct. The sequence
of the values of x are
0
0.1111
0.2222
0.3333
0.4444
0.5555
0.6666
0.7777
0.8888
1.0000
At the end of the loop,
approxIntegral=approxIntegral+(h/2)*exp(x) is executed
two times while approxIntegral=approxIntegral+h*exp(x)
is executed eight times.
EXERCISE 5
This exercise involves how to use the .m files rather than
coding with direct commands.
The dummy variable in equation 1 gives the range of values
for the function just as the matlab variable x also list the
range of values for the function. The expression y=y… also
performs the same function as the summation in equation.
The line y=zeros(size(x)) returns a matrix of zeros with the
size of x.
If the hold off and on lines are to be omitted, only one
graph would have been plotted.

EXERCISE 6
This exercise entails the use of the while loop in
modification of a previous exercise.
The purpose of the difference=TOLERANCE+1 is to
assign a value to difference which is 1 more than the value
assigned to TOLERANCE.
The purpose of k=k+1 is to provide an increment to k by 1
each time the loop iterate. The number of iterations
required may be undefined.

EXERCISE 7
Functions were usual created out of the .m files in exercise 6
0.1 tolerance requires 112 iterations.
0.05 requires 223
0.025 requires 446
0.0125 requires 784

Exercise 8
This involves the use of other commands to display results.
If the strcat was used, the roe vector and the output will be the
same.
Fprintf([‘the square root of 'num2str(i^2), is 'num2str(I),'\n'];
Fprintf(['The tangent of ',num2str(i^2)', is ',num2str(
tan(i^2)),'\n’];
Fprintf([The exponential of ',num2str(i^2)', is', num2str
(exp(i^2)),'\n’];

You might also like