Lab 1 Creating a script and publishing a report
This is the script created during the lab demonstration. The demonstration showed you how to create script, add comments to the script, use cell mode in a script, and publish a script to an HTML report.
Contents
Question 1
The radius of the earth is approximately 6.37 * 10^6 meters. (a) What is the circumference of the earth in kilometers? (b) What is the surface area of the earth in square kilometers? (C) What is the volume of the earth in cubic meters?
Question 1a
% radius of the earth in meters radius = 6.37e6; % circumference in kilometers circum = 2 * pi * radius / 1000
circum = 40023.890406734
Question 1b
% surface area in square kilometers
surfaceArea = 4 * pi * (radius / 1000)^2
surfaceArea = 509904363.781791
Question 1c
% volume in cubic meters
volume = 4 / 3 * pi * radius^3
volume = 1.08269693243e+21
Question 2
Plot the function y = x^2 for values x = -5:0.1:5 Label the x and y axes.
x = -5:0.1:5; y = x.^2; plot(x, y) xlabel('x'); ylabel('y');
