aboutsummaryrefslogtreecommitdiffstats
path: root/math2373/lab4.txt
blob: 636071616cf31dcd17e0ed94d9d09174c9ed1948 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
v.*w

ans =

    10    36    32   -12    42

v*w
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('mtimes')" style="font-weight:bold"> * </a>
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first
matrix matches the number of rows in the second matrix. To perform elementwise
multiplication, use '.*'.
} 
v.^3

ans =

     8    27    64    -8   216

v./w

ans =

    0.4000    0.2500    0.5000   -0.3333    0.8571

a = [0,1,2,3,4,5]

a =

     0     1     2     3     4     5

b=a.^3-9*a.^2+18*a

b =

     0    10     8     0    -8   -10

plot(a,b)
c=(0:0.1:5);
d=c.^3-9*c.^2+18*c;
plot(c,d);
c,d

c =

  Columns 1 through 9

         0    0.1000    0.2000    0.3000    0.4000    0.5000    0.6000    0.7000    0.8000

  Columns 10 through 18

    0.9000    1.0000    1.1000    1.2000    1.3000    1.4000    1.5000    1.6000    1.7000

  Columns 19 through 27

    1.8000    1.9000    2.0000    2.1000    2.2000    2.3000    2.4000    2.5000    2.6000

  Columns 28 through 36

    2.7000    2.8000    2.9000    3.0000    3.1000    3.2000    3.3000    3.4000    3.5000

  Columns 37 through 45

    3.6000    3.7000    3.8000    3.9000    4.0000    4.1000    4.2000    4.3000    4.4000

  Columns 46 through 51

    4.5000    4.6000    4.7000    4.8000    4.9000    5.0000


d =

  Columns 1 through 9

         0    1.7110    3.2480    4.6170    5.8240    6.8750    7.7760    8.5330    9.1520

  Columns 10 through 18

    9.6390   10.0000   10.2410   10.3680   10.3870   10.3040   10.1250    9.8560    9.5030

  Columns 19 through 27

    9.0720    8.5690    8.0000    7.3710    6.6880    5.9570    5.1840    4.3750    3.5360

  Columns 28 through 36

    2.6730    1.7920    0.8990         0   -0.8990   -1.7920   -2.6730   -3.5360   -4.3750

  Columns 37 through 45

   -5.1840   -5.9570   -6.6880   -7.3710   -8.0000   -8.5690   -9.0720   -9.5030   -9.8560

  Columns 46 through 51

  -10.1250  -10.3040  -10.3870  -10.3680  -10.2410  -10.0000

e =(-2:0.2:6);
g = e.^3-5*e.^2-4*e+20

g =

  Columns 1 through 9

         0    5.1680    9.5040   13.0560   15.8720   18.0000   19.4880   20.3840   20.7360

  Columns 10 through 18

   20.5920   20.0000   19.0080   17.6640   16.0160   14.1120   12.0000    9.7280    7.3440

  Columns 19 through 27

    4.8960    2.4320         0   -2.3520   -4.5760   -6.6240   -8.4480  -10.0000  -11.2320

  Columns 28 through 36

  -12.0960  -12.5440  -12.5280  -12.0000  -10.9120   -9.2160   -6.8640   -3.8080         0

  Columns 37 through 41

    4.6080   10.0640   16.4160   23.7120   32.0000

plot(e,g)
d = (0, 2, 4, 5, 6, 8)
 d = (0, 2, 4, 5, 6, 8)
       ↑
{Error: Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
} 
d = [0, 2, 4, 5, 6, 8]

d =

     0     2     4     5     6     8

f = [0, 20, 30, 50, 70, 100];
plot(d,f,’r:p’);
 plot(d,f,’r:p’);
          ↑
{Error: Invalid text character. Check for unsupported symbol, invisible character, or
pasting of non-ASCII characters.
} 
plot(d,f,'r:p');
plot(d,f,'b:s');
plot(d,f,’b:p’);
 plot(d,f,’b:p’);
          ↑
{Error: Invalid text character. Check for unsupported symbol,
invisible character, or pasting of non-ASCII characters.
} 
xlabel('Dog years');
ylabel('Human years');
title('The passage of time')
plot(d,f,'b:p');
q = [0,2,4,5,6,8]

q =

     0     2     4     5     6     8

q = [0,2,4,5,6,8];
r = [0,20,30,30,50,100];
plot(d,f,'r:p');
hold on
lsline
hold off
plot(q,r,'r:p');
lsline;
man
{Undefined function or variable 'man'.
} 
xlabel('Decades of Life')
ylabel('Likliness of Death');
title('Funny Graph Title');
diary off