Day 3:
We spent our time learning about formatting our answers and finding ways to use the fprintf command. We then learned about m-scrpit file and how to save work.
We then worked on a UDF example. Here is a picture.
We then worked on the Voyager 1 and Voyager 2 power consumption. Here is a picture.
We then talked about the weather and how weather data could be transferred from excel file to matlab reading file that can be used to deduct information.
Conclusion:
We spent the learning ways to use the fprintf format to better showcase our answers then we learned about m-scripts and their usefulness. Later on we found ways to use excel files to import into Matlab, which will be useful for the homework.
HMWK 3
Q1
lat1 = input('latitude 1 in deg \n'); %input for lat1
long1 = input('longitude1 in deg \n'); %input fot long1
lat2 = input('latitude2 in deg \n'); %input for lat2
long2 = input('longitude2 in deg \n'); %input for long2
rho = unit(3960,'miles') %convertto si units
rb = 3960 %radius of earth in miles
phi = (90 - lat1)*(pi/180) %converts lat1 deg into rad
p1 = unit(lat1,'deg')
lat1*(pi/180)
theta = (360 - long1)*(pi/180) %converts long1 deg into rad
t1 = unit(long1,'deg')
long1*(pi/180)
x1 = rho*sin(phi)*cos(theta) %conver lat into spherical x
y1 = rho*sin(phi)*sin(theta) %conver long into spherical y
z1 = rho*cos(phi) %conver r into spherical r
phi2 = (90 - lat2)*(pi/180) %converts lat2 deg into rad
theta2 = (360 - long2)*(pi/180) %converts long2 deg into rad
x2 = rho*sin(phi2)*cos(theta2) %conver lat into spherical x2
y2 = rho*sin(phi2)*sin(theta2)%conver long into spherical y2
z2 = rho*cos(phi2) %conver r2 into spherical r2
dot = x1*x2 + y1*y2 + z1*z2 %dot of lat,long
dist1 = sqrt(x1*x1 + y1*y1 + z1*z1) %mag of 1
dist2 = sqrt(x2*x2 + y2*y2 + z2*z2) %mag of 2
gamma = acos(dot/(dist1*dist2)) %eq for gamma
% t2 = unit(lon2,'deg')
% xd = rho*sin(p2)*cos(t2)
% ye = rho*sin(p2)*sin(t2)
% zf = rho*cos(p2)
% p2 = unit(lat2,'deg')
% xa = rho*sin(p1)*cos(t1)
% yb = rho*sin(p1)*sin(t1)
% zc = rho*cos(p1)
% dot1 = xa*xd + yb*ye + zc*zf
% dista = sqrt(xa*xa + yb*yb + zc*zc)
% distb = sqrt(xd*xd + ye*ye + zf*zf)
% gamma1 = acos(dot1/(dista*distb))
gamma*rb %eq for real distance between two points
display('Great Circle Distance in miles:') %display
fprintf('%8.0f \n',gamma*rb) %display of data
display('Great Circle Distance in meters:')
% sprintf('%8.0f \n',gamma*rho)
%%hmwk 3 - 2
tt= b4 %tt is the excel of therm 1,2,3
ttt = b4' %ttt is the transpose of thermo 1,2,3
ttm = max(tt) %max temp for each of therm
tttm = max(ttt)
ttmin = min(tt) %min tem for teach therm
tttm2 = max(max(ttt)) %higest temp for therm
%%hmwk 3 - 3
r = randn(10000,1)*23.5+80; %creates a gauss random number
r1 =mean(r) %mean for gaussian random number
st = std(r) %standard dev of r numbers
y = st*r+r1
%%hmwk 3 - 4
zl = 0+5j %res of inductor
zc = 0+15j %resof cap
R = 5+0j %res of res
zt = zc+zl+R %res of circuit
V = 10+0j %% V = Izt
I = complex(V/zt) %current of circuit
%%hmwk 3 - 5
% Covina = 34.1,-117.9 ; 34.2,-118.4 no good
% weathr st = 33.9,-118.4
lat1 = input('latitude 1 in deg \n'); %input for lat1
long1 = input('longitude1 in deg \n'); %input fot long1
lat2 = input('latitude2 in deg \n'); %input for lat2
long2 = input('longitude2 in deg \n'); %input for long2
rho = unit(3960,'miles') %convertto si units
rb = 3960 %radius of earth in miles
phi = (90 - lat1)*(pi/180) %converts lat1 deg into rad
p1 = unit(lat1,'deg')
lat1*(pi/180)
theta = (360 - long1)*(pi/180) %converts long1 deg into rad
t1 = unit(long1,'deg')
long1*(pi/180)
x1 = rho*sin(phi)*cos(theta) %conver lat into spherical x
y1 = rho*sin(phi)*sin(theta) %conver long into spherical y
z1 = rho*cos(phi) %conver r into spherical r
phi2 = (90 - lat2)*(pi/180) %converts lat2 deg into rad
theta2 = (360 - long2)*(pi/180) %converts long2 deg into rad
x2 = rho*sin(phi2)*cos(theta2) %conver lat into spherical x2
y2 = rho*sin(phi2)*sin(theta2)%conver long into spherical y2
z2 = rho*cos(phi2) %conver r2 into spherical r2
dot = x1*x2 + y1*y2 + z1*z2 %dot of lat,long
dist1 = sqrt(x1*x1 + y1*y1 + z1*z1) %mag of 1
dist2 = sqrt(x2*x2 + y2*y2 + z2*z2) %mag of 2
gamma = acos(dot/(dist1*dist2)) %eq for gamma
gamma*rb %eq for real distance between two points
display('Great Circle Distance in miles:') %display
fprintf('%8.0f \n',gamma*rb) %display of data
display('Great Circle Distance in meters:')
tt = wd2; %tt is weather data
ttt = wd2' %ttt is transpose of weather data
t1 = sum(wd2) %t1 sum of weater data
t2 = sum(ttt) %t2 sum of weather data
format shorteng %format numbers
t1 = sum(wd2) %t1 sum of weather data
t2 = sum(wd2') %t2 sum of weather data
No comments:
Post a Comment