Question: Using Matlab only answer the following. Solve each problem in a separate script file and name it as initials-HW-06-pb-##. m. Copy the results from the
Solve each problem in a separate script file and name it as initials-HW-06-pb-##. m. Copy the results from the Command Window at the end of the script file and comment them. If the problem requires a function file you should include it in your submission. Make sure that all your script files contain enough comments and description for different steps. Commands:clc, clear, format compact, sqrt, size, length, fprintf, array indexing, max, min, sum, mean, norm, linspace, colon operator (), array operations, matrix operations, inv, transpose("),poly, roots, polyval, conv, deconv, close plot, xlabel, ylabel, grid, legend, input, function, e, load, save, xlsread, xlswrite, if, else, elseif, end, round, r, mod, ceil, floor, fix, for, continue, break Topics:if statement, nargin, error, for loop with if, continue, break, switch&case Q1. Write a function file (name it Initials_RectPyr) that finds the Surface Area (S4) and the volume (Vof a Rectangular Pyramid if the height, h, base length, I, and base width, w, are given. The function should have 3 arguments for the input (h, I, and w and 2 arguments for the output (SA and ). Knowing that the Square Pyramid is a special case of the Rectangular Pyramid in which the base length and width are equal a:1 #w, customize the function so that if the user entered only 2 arguments for the input, it considers the case of a square pyramid and uses equal sides for the base. Use the error command to display an error message if the user entered only l argument for the input. Hint: Use if statement with nargin Write a script file that defines H, L &W one time then call the function to find SA & V then define only H & L to find SA & V. Test your function with H-4, L-3, w 5, H-4, L-3, w-3 and H- L-3 [A,V-RectPyr (4,3,3) >[A,v-RectPyr (4,3)>> [A,VI-RectPyr (4) Error using RectPyx (1ine4) At least 2 dimensions are needed 4.6320 34.6320 12 12
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
