MEEN210 L04 Arrays+Matrix
MEEN210 L04 Arrays+Matrix
>> c= [ 8 9 10 11]
a = [2 3 4] b= [5 c = [ 8 9 10 11]
6
7]
What are “a”, “b”, and “c” called?
Vectors (Arrays)
Multiplication (continued)
f1234 = b*a = = > [3x1] * [1x3] = ?
MATLAB
>> f1234=b*a
f1234 =
10 15 20
12 18 24
14 21 28
MATLAB Session 2.1 MATLAB Fundamentals Chapter 2
Vectors, Arrays and Matrices
Multiplication (continued)
f1234 is a,
Matrix [3x3]
This can be system of coefficients from a
equations – you will solve later this
semester.
Multiplication (continued)
f12345 = 2 * f1234 ?
MATLAB
>> f1234=b*a
f12345 = 2 * f1234
20 30 40
24 36 48
28 42 56
>> hhtrans=hh’
>> wtrans = w’
We want to do “Element-by-Element”
operations in MATLAB
MATLAB wants to know when a variable is a
vector or matrix!
____________________________________________________
>> y = yfunc(x); (to call the function)
>> x1 = 0:0.1:pi;
>> y1 = cos(x1);
>> y2 = sin(x1);
>> hhc=hh’
hhc =
0.0998
0.9801
0.3093
MATLAB Session 2.1 MATLAB Text Chapters 2 & 3
Class Problem 2.1.6 (output from MATLAB - Blue)
>> wc = w’
wc =
23
31
57
>> tt_tt = w * wc
tt_tt =
4739
>> ssSam = hhc * hh
ssSam =
0.0100 0.0978 0.0309
0.0978 0.9605 0.3032
0.0309 0.3032 0.0957
MATLAB Session 2.1 MATLAB Text Chapters 2 & 3
Class Problem 2.1.7
Type in the following commands, MATLAB Command Window:
>> xxx = 1:1:100
xxx =
Columns 1 through 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 16
Columns 17 through 32
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Columns 33 through 48
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Columns 49 through 64
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
Columns 65 through 80
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
Columns 81 through 96
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
Columns 97 through 100
97 98 99 100
>> x=linspace(0,0.13,1000);
>> y=linspace(0,9,1000);
>> hold on