aboutsummaryrefslogtreecommitdiffstats
path: root/math2373/lab9.txt
blob: 507980360d20491f5071431f73966ec272dbb1cb (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
t=[0:2:100]

t =

  Columns 1 through 11

     0     2     4     6     8    10    12    14    16    18    20

  Columns 12 through 22

    22    24    26    28    30    32    34    36    38    40    42

  Columns 23 through 33

    44    46    48    50    52    54    56    58    60    62    64

  Columns 34 through 44

    66    68    70    72    74    76    78    80    82    84    86

  Columns 45 through 51

    88    90    92    94    96    98   100

clear
t=[0:2:100];
x=10+exp(-0.2618*t)

x =

  Columns 1 through 6

   11.0000   10.5924   10.3509   10.2079   10.1231   10.0729

  Columns 7 through 12

   10.0432   10.0256   10.0152   10.0090   10.0053   10.0032

  Columns 13 through 18

   10.0019   10.0011   10.0007   10.0004   10.0002   10.0001

  Columns 19 through 24

   10.0001   10.0000   10.0000   10.0000   10.0000   10.0000

  Columns 25 through 30

   10.0000   10.0000   10.0000   10.0000   10.0000   10.0000

  Columns 31 through 36

   10.0000   10.0000   10.0000   10.0000   10.0000   10.0000

  Columns 37 through 42

   10.0000   10.0000   10.0000   10.0000   10.0000   10.0000

  Columns 43 through 48

   10.0000   10.0000   10.0000   10.0000   10.0000   10.0000

  Columns 49 through 51

   10.0000   10.0000   10.0000

clear
t=[0:2:100];
x=10+exp(-0.2618*t);
Q=[-14.4721 10 -5.5279; 8.9443 -10 -8.9443; -5.5279 10 -14.4721];
x=10+Q*exp(-0.2618*t);
{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 '.*'.
} 
x=10+Q.*exp(-0.2618*t);
{Matrix dimensions must agree.
} 
x=10+Q[1:].*exp(-0.2618*t);
 x=10+Q[1:].*exp(-0.2618*t);
       ↑
{Error: Invalid expression. When calling a function or indexing a
variable, use parentheses. Otherwise, check for mismatched
delimiters.
} 
x=10+Q[:1].*exp(-0.2618*t);
 x=10+Q[:1].*exp(-0.2618*t);
       ↑
{Error: Invalid expression. When calling a function or indexing a
variable, use parentheses. Otherwise, check for mismatched
delimiters.
} 
x=10+Q.*exp(-0.2618*t);
{Matrix dimensions must agree.
} 
x=10+Q(:,1).*exp(-0.2618*t);
plot(t,x)
x=10+Q(1,:).*exp(-0.2618*t);
{Matrix dimensions must agree.
} 
x=10+Q(:,1).*exp(-0.2618*t);
plot(t,x)
clear x
x=10+Q(:,1).*exp(-0.2618*t);
clear x
Q(:,1)

ans =

  -14.4721
    8.9443
   -5.5279

x=10+Q(:,1)*exp(-0.2618*t);
x=10+Q(1,:)*exp(-0.2618*t);
{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
'.*'.
} 
x=10+Q(:,1)*exp(-0.2618*t);
plot(t,x)
x=10+Q(1)*exp(-0.2618*t);
Q(1)

ans =

  -14.4721

x=10+Q(1)*exp(-0.2618*t)+Q(2)*exp(-0.2618*t)+Q(3)*exp(-0.2618*t);
plot(t,x)
F=-.2618; x=10+Q(1)*exp(F*t)+Q(2)*exp(F*t)+Q(3)*exp(F*t);
plot(t,x);
hold on;
F=-.2618, y=3; y=10+Q(y+1)*exp(F*t)+Q(y+2)*exp(F*t)+Q(y+3)*exp(F*t);

F =

   -0.2618

F=-.2618; y=3; y=10+Q(y+1)*exp(F*t)+Q(y+2)*exp(F*t)+Q(y+3)*exp(F*t);
plot(t,y)
F=-0.2; y=3; y=10+Q(y+1)*exp(F*t)+Q(y+2)*exp(F*t)+Q(y+3)*exp(F*t);
plot(t,y)
hold off
plot(t,x)
Q(4)

ans =

    10

Q(3
 Q(3
    ↑
{Error: Invalid expression. When calling a function or indexing a
variable, use parentheses. Otherwise, check for mismatched
delimiters.
} 
Q(3)

ans =

   -5.5279

Q(0)
{Array indices must be positive integers or logical values.
} 
Q(4)

ans =

    10

Q(5)

ans =

   -10

Q(6)

ans =

    10

Q(7)

ans =

   -5.5279

Q(8)

ans =

   -8.9443

Q(9)

ans =

  -14.4721

Q(10)
{Index exceeds array bounds.
} 
Q(5)

ans =

   -10

Q(6)

ans =

    10

F=-0.2; y=3; y=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
F=-0.2; y=0; x=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
{Index in position 1 is invalid. Array indices must be positive
integers or logical values.
} 
F=-0.2; y=1; x=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
F=-0.2618; y=1; x=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
plot(t,x)
hold on;
F=-0.2; y=2; x=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
plot(t,y)
F=-0.2618; y=1; x=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
F=-0.2; y=2; y=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
plot(t,y)
clear plot
F=-0.2618; y=1; x=10+Q(y,1)*exp(F*t)+Q(y,2)*exp(F*t)+Q(y,3)*exp(F*t);
F=-0.2618; z=2; y=10+Q(z,1)*exp(F*t)+Q(z,2)*exp(F*t)+Q(z,3)*exp(F*t);
F=-0.2; z=2; y=10+Q(z,1)*exp(F*t)+Q(z,2)*exp(F*t)+Q(z,3)*exp(F*t);
plot(t,y)
plot(t,x)
hold onl
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('hold', '/soft/MATLAB/R2018a/toolbox/matlab/graphics/hold.m', 83)" style="font-weight:bold">hold</a> (<a href="matlab: opentoline('/soft/MATLAB/R2018a/toolbox/matlab/graphics/hold.m',83,0)">line 83</a>)
Unknown command option.
} 
hold on
plot(t,y)
F=-0.2; z=2; y=10+Q(z,1)*exp(F*t)+Q(z,2)*exp(F*t)+Q(z,3)*exp(F*t);
Q(2,1)

ans =

    8.9443

F=-0.2; z=2; y=10+Q(z,1)*exp(F*t)+Q(z,2)*exp(F*t)+Q(z,3)*exp(F*t);
F=-0.2; a=2; z=10+Q(a,1)*exp(F*t)+Q(a,2)*exp(F*t)+Q(a,3)*exp(F*t);
F=-0.0382; a=3; z=10+Q(a,1)*exp(F*t)+Q(a,2)*exp(F*t)+Q(a,3)*exp(F*t);
plot (t,z)
clear plot;
plot (t,x)
plot (t,z)
plot (t,x)
hold on
plot (t,z)
F=-0.2; z=2; y=10+Q(z,1)*exp(F*t)+Q(z,2)*exp(F*t)+Q(z,3)*exp(F*t);
plot(t,y)
plot(t,x); plot(t,y) plot(t,z)
 plot(t,x); plot(t,y) plot(t,z)
                      ↑
{Error: Invalid expression. Check for missing multiplication
operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of
parentheses.
} 
plot(t,x); plot(t,y); plot(t,z)
clear plot
plot(t,x); hold on; plot(t,y); plot(t,z)
plot(t,x); plot(t,y); plot(t,z)
hold on
plot(t,x); plot(t,y); plot(t,z)
F=-0.2; z=2; y=10+Q(z,1)*exp(F*t)+Q(z,2)*exp(F*t)+Q(z,3)*exp(F*t);
plot(t,x); plot(t,y); plot(t,z)
F=-0.0382; a=3; z=10+Q(a,1)*exp(F*t)+Q(a,2)*exp(F*t)+Q(a,3)*exp(F*t);
plot(t,x); plot(t,y); plot(t,z)
hold on;
plot(t,x); plot(t,y); plot(t,z)
F=-0.0382; z=10+Q(a,1)*exp(-.2618*t)+Q(a,2)*exp(-.2*t)+Q(a,3)*exp(-.0382*t);
a=1; z=10+Q(a,1)*exp(-.2618*t)+Q(a,2)*exp(-.2*t)+Q(a,3)*exp(-.0382*t);
a=1; x=10+Q(a,1)*exp(-.2618*t)+Q(a,2)*exp(-.2*t)+Q(a,3)*exp(-.0382*t);
a=2; y=10+Q(a,1)*exp(-.2618*t)+Q(a,2)*exp(-.2*t)+Q(a,3)*exp(-.0382*t);
a=3; z=10+Q(a,1)*exp(-.2618*t)+Q(a,2)*exp(-.2*t)+Q(a,3)*exp(-.0382*t);
hold on;
plot(t,x); plot(t,y); plot(t,z)
plot(t,x,'b:s'); plot(t,y,'r:p'); plot(t,z,'g,t')
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('plot')" style="font-weight:bold">plot</a>
Error in color/linetype argument.
} 
plot(t,x,'b:s'); plot(t,y,'r:p'); plot(t,z,'g,o')
{Error using <a href="matlab:matlab.internal.language.introspective.errorDocCallback('plot')" style="font-weight:bold">plot</a>
Error in color/linetype argument.
} 
plot(t,x,'b:s'); plot(t,y,'r:p'); plot(t,z,'-o')
t.label("time")
{Dot indexing is not supported for variables of this type.
} 
t.label('time')
{Dot indexing is not supported for variables of this type.
} 
x.label('time')
{Dot indexing is not supported for variables of this type.
} 
xlabel('time')
xlabel('Time')
ylabel('Amount of salt')
xlabel('Time (seconds)')
xlabel('Time (min)')
plot(t,x,'b:s'); plot(t,y,'r:p'); plot(t,z,'-o')
xlabel('Time (min)')
ylabel('Amount of salt')
hold on;
plot(t,x,'b:s'); plot(t,y,'r:p'); plot(t,z,'-o')
xlabel('Time (min)')
ylabel('Amount of salt')