Day 2:
This day we got familiar with matlab math writing. Using the syntax of matlab. Some operations make sense if real world but not in matlab world.
Here is a picture of matlab code running.
We then example with PV = nRT. Here is a picture.
We then did an example unit conversion from the mars rover. Here is a picture.
Conclusion:
We learned how to type our understanding of math equations into the matlab syntax. We did tried relating it to the PV = nRT equations and do some unit conversions into SI units.
%HMWK 2
x = [-2:1:2]%vector x -2to2 by 1
abs(x) %absolute of x
sqrt(x) %square root of x
%#2
x1=[-3,3] %vector x2 -3,3
sqrt(x1) %square rot of x1
nthroot(x1,2) %nth root
x1.^(.5) %x1^(.5) power
%#3
x3 = [-9:3:12] %vector x3 -9to12 by 3
x3/2 %vector/2
rem(x3,2) %vector rem of 2
exp(x3) %vector exp
sign(x3) %sign for vector
%#4
factor(322) %factor
gcd(322,6) %greatest common denometer
isprime(322) %cheks if # is prime
primes(322) %numbers of prime up to 322
factorial(10) %10!
nchoosek(20,3) %Max # groups of 3 from 20-nomatter
%#5 P= Pnot*e^(rt)
pnot = 100 %intial pop
r = (9/10) %growth rate in fraction
t=10 %time in year
p = pnot*exp(r*t) %pop formula
pnot = input('intial pop \n') %input pop intial
r = input('growth rate in fraction \n') %input growth
t = input ('time in year \n') %input year
p=pnot*exp(r*t) %output for pop
%#6
bulb = 20*100 %J/s
app = 4*500 %J/s
out = 3000 %J/s
a1 = bulb*app*out %energy remove J/s
air = 2000 %aircond remove J/s
temp1 = a1/air %number of air needed for constant temp
bulb2 = 20*18 %new J/s for bulb at 18
a2 = bulb2*app*out %energy remove J/s
temp2 = a2/air %aircond remove J/s
bulb3 = input('# of bulbs \n')*100 %input for bulbs
app3 = input('# of appliances \n')*500 %input for apps
air3 = bulb3*app3/air %number of airconditoner needed
%#6 n!/(n-m)!
nchoosek(4,1) %line of 4
nchoosek(28,7) %differnt robo team -notmatter
factorial(28)/(factorial(28-7)) %differnt robo team - matter
nchoosek(52,5) %diff hands of 5
4/(nchoosek(52,5)) %chance of royal fush
******************ANS********************
x =
-2
-1 0 1
2
ans =
2
1 0 1
2
ans =
0.0000 + 1.4142i 0.0000 + 1.0000i 0.0000 + 0.0000i 1.0000 + 0.0000i 1.4142 + 0.0000i
sqrt(x1) %square rot of x1
nthroot(x1,2) %nth
root
x1.^(.5)
Undefined function
or variable 'x1'.
x1=[-3,3]
%vector x2 -3,3
sqrt(x1) %square rot of x1
nthroot(x1,2) %nth
root
x1.^(.5)
x1 =
-3
3
ans =
0.0000 + 1.7321i 1.7321 + 0.0000i
Error using nthroot
(line 31)
If X is negative, N
must be an odd integer.
x3 = [-9:3:12] %vector x3 -9to12 by 3
x3 = [-9:3:12] %vector x3 -9to12 by 3
x3/2 %vector/2
rem(x3,2) %vector
rem of 2
exp(x3) %vector exp
sign(x3) %sign for vector
%#4
factor(322) %factor
gcd(322,6) %greatest common denometer
isprime(322) %cheks if # is prime
primes(322)
%numbers of prime up to 322
factorial(10) %10!
nchoosek(20,3) %Max # groups of 3 from 20-nomatter
%#5 P= Pnot*e^(rt)
pnot = 100 %intial
pop
r = (9/10) %growth rate in fraction
t=10 %time in year
p = pnot*exp(r*t)
%pop formula
pnot =
input('intial pop \n') %input pop
intial
r = input('growth
rate in fraction \n') %input growth
t = input ('time in
year \n') %input year
p=pnot*exp(r*t)
%output for pop
%#6
bulb = 20*100 %J/s
app = 4*500 %J/s
out = 3000 %J/s
a1 = bulb+app+out
%energy remove J/s
air = 2000 %aircond
remove J/s
temp1 =
round(a1/air) %number of air needed for
constant temp
bulb2 = 20*18 %new J/s for bulb at 18
a2 = bulb2+app+out
%energy remove J/s
temp2 =
round(a2/air) %aircond remove J/s
bulb3 = input('# of
bulbs \n')*100 %input for bulbs
app3 = input('# of
appliances \n')*500 %input for apps
air3 =
round((bulb3+app3)/air) %number of airconditoner needed
%#6 n!/(n-m)!
nchoosek(4,1) %line of 4
nchoosek(28,7) %differnt robo team -notmatter
factorial(28)/(factorial(28-7))
%differnt robo team - matter
nchoosek(52,5) %diff hands of 5
4/(nchoosek(52,5)) %chance of royal fush
x3 =
-9
-6 -3 0
3 6 9
12
ans =
-4.5000
-3.0000 -1.5000 0
1.5000 3.0000 4.5000
6.0000
ans =
-1
0 -1 0
1 0 1
0
ans =
1.0e+05 *
0.0000
0.0000 0.0000 0.0000
0.0002 0.0040 0.0810
1.6275
ans =
-1
-1 -1 0
1 1 1
1
ans =
2
7 23
ans =
2
ans =
0
ans =
Columns 1 through 20
2
3 5 7
11 13 17
19 23 29
31 37 41
43 47 53
59 61 67
71
Columns 21 through 40
73
79 83 89
97 101 103
107 109 113
127 131 137
139 149 151
157 163 167
173
Columns 41 through 60
179
181 191 193
197 199 211
223 227 229
233 239 241
251 257 263
269 271 277
281
Columns 61 through 66
283
293 307 311
313 317
ans =
3628800
ans =
1140
pnot =
100
r =
0.9000
t =
10
p =
8.1031e+05
intial pop
100
pnot =
100
growth rate in
fraction
.9
r =
0.9000
time in year
10
t =
10
p =
8.1031e+05
bulb =
2000
app =
2000
out =
3000
a1 =
7000
air =
2000
temp1 =
4
bulb2 =
360
a2 =
5360
temp2 =
3
# of bulbs
10
bulb3 =
1000
# of appliances
8
app3 =
4000
air3 =
3
ans =
4
ans =
1184040
ans =
5.9676e+09
ans =
2598960
ans =
1.5391e-06
No comments:
Post a Comment