Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Kaitlyne Kramer
- %section 002
- %Lab10
- %note: used textbook and mathworks.com
- clear
- clc
- %Problem 1: determine how far a free falling object falls in five second
- % intervals for o to 3 minutes. Using array operations calculate
- % a row vector that has the distance the object fell for each of
- % the increments. Make a 2-D array that has the times in the
- % first column and distances in the second.
- %input needed: times from 0 to 3 minutes, in five second increments.
- %output: a table with the times in the first column and distances in the
- % second.
- %processing: the equation for a free-falling object i given by D=1/2gt^2
- % g= 9.8 m/s^2
- g= 9.8;
- time = linspace(0,180,37);
- distance= 0.5*g *time .^2;
- table = [time' , distance']
- %problem 2: use the input function and prompt the user to enter the side of
- % six cubes. Then, determine the radii of the spheres that have
- % the same surface area as the cubes and then the volume as the
- % cubes.
- %input: 6 side of the cubes
- %output: radii of the spheres that have the same surface area as the cubes
- % and radii of the spheres that have the same volume as the cubes
- %processing: prompt user for side values and then calculate volume and
- % surface area. Using these values, calculate the radius for spheres that
- % would have the same volume as the cube and then the same surface area.
- %prompt user for data
- prompt = 'please enter a value for the side of the cube';
- side1= input(prompt);
- side2= input(prompt);
- side3= input(prompt);
- side4= input(prompt);
- side5= input(prompt);
- side6= input(prompt);
- cubes = [side1, side2, side3, side4, side5, side6];
- %calculate volume and surface area
- volume= power(cubes,3);
- surfacearea= 6*power(cubes,2);
- %find radius of spheres with the same volume and surface area as the cube
- sameradiusforvolume= power(((volume/pi)*3/4),1/3);
- sameradiusforSA= power(((surfacearea/(4*pi))),1/2);
- %display values
- disp('Sphere radiuses for spheres with the same volume as the cube are');
- disp(sameradiusforvolume);
- disp ('Sphere radiuses for spheres with the same surface area as the cube are');
- disp (sameradiusforSA);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement