You are on page 1of 8

LABORATORY EXERCISE NO.

1
INTRODUCTION TO MATLAB

Gallano,
Name : Soriano,
Name Edwin
John Carlo D. A.
:________________________
Section: _______________________________
CEIT-29-801E
Section:________________________

PROCEDURE ANSWERS:
>> A=[ 1 2 3 4 5 6 7]
A=
1 2 3 4 5 6 7
>> B= [ 2 2 1 2 4 2 1]
B=
2 2 1 2 4 2 1

>> C=A-B
C=
-1 0 2 2 1 4 6

>> A-C
ans =
2 2 1 2 4 2 1

>> A+B
ans =
3 4 4 6 9 8 8

>> A.*C
ans =
-1 0 6 8 5 24 42

>> A.*B
ans =
2 4 3 8 20 12 7

>> A*2
ans =
2 4 6 8 10 12 14

>> A^2
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a
scalar. To
perform elementwise matrix powers, use '.^'.

>> A.^2
ans =
1 4 9 16 25 36 49

>> A.^C
ans =
1 1 9 16 5 1296 117649

>> A^C
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a
scalar. To
perform elementwise matrix powers, use '.^'.

>> A == C
ans =
1×7 logical array
0 0 0 0 0 0 0

>> A>6
ans =
1×7 logical array
0 0 0 0 0 0 1

>> A>C
ans =
1×7 logical array
1 1 1 1 1 1 1

>> C-(A>2)
ans =
-1 0 1 1 0 3 5

>> (A>2)&(A<6)

ans =
1×7 logical array
0 0 1 1 1 0 0

>> (A>2)|((A<6))
ans =
1×7 logical array
1 1 1 1 1 1 1

>> any(A)

ans =
logical
1

>> all(A)
ans =
logical
1

>>
TASK ANSWERS:
1.
2.

3.
4.

5.
6.

7.
QUESTIONS:
1. What are your observations in the result of procedure 4?
As I observe the result of procedure 4, I can say that using the semicolon functions to increment
decrement the arrays.
2. What are the differences in using editor and command window?
As I learn using the MATLAB, I noticed the difference between using the MATLAB editor and the
MATLAB command window. MATLAB editor lets us input, edit, as well as save through mfile
whereas the MATLAB command window lets us input the commands in direct to the MATLAB
interpreter
3. What are the errors you encountered while performing the task? How did these errors happen?
Explain how did you correct the errors
Performing the task gives me no result errors.

You might also like