Question

In: Mechanical Engineering

1. A square-based pyramid has the volume V. If the vertical height is H (the normal...

1. A square-based pyramid has the volume V. If the vertical height is H (the normal distance from the square base to the point), write a MATLAB function that:

has V and H as input arguments

calculates the length of the side of the square (S)

has S as an output argument

Write MATLAB code that tests the function for the values:

V = 10 m3 and H = 2 m.

V = 2.586×106 m3 and H = 146.6 m (the original dimensions of the Great Pyramid of Giza).

2. Repeat SPIDER 2 Q1, but write a function that accepts a year as an input argument and determines whether that year is a leap year. The output should be the variable extra_day, which should be 1 if the year is a leap year and 0 otherwise.

You must write a script file that thoroughly tests whether your function works correctly.

Solutions

Expert Solution

% Matlab script to test the computation of length of a side of a square
% for given Volume of pyramid and its height
clc;
% test-1
V=10;
H=2;
S=lengthOfSideofSquare(V,H);
fprintf('\nfor volume %f, Height %f,Length of side of square is : %f',V,H,S);
% test-2
V=2.586*(10^6);
H=146.6;
S=lengthOfSideofSquare(V,H);
fprintf('\nfor volume %f, Height %f,Length of side of square is : %f',V,H,S);

%--------------------------------------------------------

%function file: lengthOfSideofSquare.m

function S= lengthOfSideofSquare(V,H)
% lengthOfSideofSquare accepts Volume and height of a square based
% Pyramid and returns length of a side of the square
S=sqrt((3*V)/H);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%output:

QUESTION NO-2

As details od Spider 2 Q-1 is not supplied , I sen here only the part you want to enhance.i,e test of an extra day.

% SCRIPT FILE:

% Script file to test a year contains an extra day(leap year)
clc;
year=2016;
extra_day=isLeapYear(year)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Function file : isLeapYear.m

function extra_day = isLeapYear(year)
% isLeapYear(year) returns 1 if year is a leap, 0 otherwise
if ( mod(year,4) ==0 && mod(year,100) ~=0) || mod(year,400)==0
extra_day=1;
else
extra_day=0;
end
end

%%%%%%%%%%%%%%%%%%%%%%

%Output


Related Solutions

Three jars each have volume V and height h, but they have different shapes as shown...
Three jars each have volume V and height h, but they have different shapes as shown in (Figure 1) . Water is to be added to each jar and the pressure is to be measured right at the bottom of each jar. Figure 1 Part A Rank the jars in order of decreasing pressure if the volume of water is V. Rank from largest to smallest. To rank items as equivalent, overlap them. Pa, Pc , Pb or correct ranking...
The base of a right pyramid is an equilateral triangle of perimeter 8 cm and the height of the pyramid is 30√3 cm . Find the area and volume of the pyramid.
The base of a right pyramid is an equilateral triangle of perimeter 8 cm and the height of the pyramid is 30√3 cm . Find the area and volume of the pyramid.
Suppose you have a trapezoid a vertical height of H with bottom and top widths of...
Suppose you have a trapezoid a vertical height of H with bottom and top widths of B and T. Suppose we draw a line of height h that is parallel to the base of the trapezoid. What are the dimensions of the new trapezoid? (i.e. top widths and height)
The molecule ClF5 has a C4V point group and square pyramid shape.
Inorganic Chemistry EXPERTS onlyThe molecule ClF5 has a C4V point group and square pyramid shape. Fill in the blanks by identifying all of the symmetry operations. Also, provide reasoning.E2C4C22 sigma v2 sigma d5
Prove that a full m-ary tree of height h has at least h(m − 1) leaves.
Prove that a full m-ary tree of height h has at least h(m − 1) leaves.
The volume of a cylinder is V space equals space pi space r squared space h,...
The volume of a cylinder is V space equals space pi space r squared space h, where r is the radius of the circular faces and h is the height of the cylinder. Your measurements show that the mean value of r is 21 cm and its statistical and instrumental uncertainties turned out to be 0.10 cm and 0.20 cm, respectively. Likewise, that of h are 13 cm for the mean, 0.2 cm (statistical) and 0.3 cm (instrumental) for its...
Let b be a vector that has the same height as a square matrix A. How...
Let b be a vector that has the same height as a square matrix A. How many solutions can Ax = b have?
Volume-Volume percent: 10 mL ice cold 4 % acetic acid in 95 % ethanol (v/v) 1....
Volume-Volume percent: 10 mL ice cold 4 % acetic acid in 95 % ethanol (v/v) 1. how many mL of acetic acid and how many mL of ethanol is needed to make 10 mL mixture of the two
A reinforced concrete beam has square cross section (h × h). There are 9 steel reinforcing...
A reinforced concrete beam has square cross section (h × h). There are 9 steel reinforcing bars (each of diameter ds), 3 evenly spaced towards the top, 3 along the neutral axis, and 3 evenly spaced towards the bottom. The vertical distance from the centre of the bar to top (or bottom) edge of the section is called the cover, and is denoted as e. It should be taken that ρsteel = 7850 kg/m3, ρconcrete = 2350 kg/m3, Econcrete =...
1. A manufacturing company manufactures a cardboard box with a square base and a height of...
1. A manufacturing company manufactures a cardboard box with a square base and a height of 15 inches. Suppose the equation x2 +60x- 7,200 = 0 can be used to find the length and width of the base of the box, each measuring x inches. Write the equation in factored form. Use the zero product property to solve the equation. Show all the steps needed to find both answers. Explain how the solution relates to this situation 2. City engineers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT