Question
Use Matlab... Use the given variables please... Replace 0 and [].... %problem 1 disp('*****problem 1*****'); %height, width and depth values for test cases h =
Use Matlab...
Use the given variables please...
Replace 0 and []....
%problem 1
disp('*****problem 1*****');
%height, width and depth values for test cases
h = [5 1 2];
w = [3 8 2];
d = [2 4 10];
%initializing results
sa = zeros(1,3);
vol = zeros(1,3);
%example of the left-hand side of the function call, assuming the function
%arguments are scalars. If the function arguments are arrays, remove the
%index
[vol(1), sa(1)] = dummy(); %replace dummy with your function name
%problem 2
disp('*****problem 2*****');
prob2a1 = 0;
prob2a2 = 0;
x = [];
prob2b = dummy(); %replace dummy with your function name
figure(1);
Application 4: User-defined functions and plotting Designed to test skills: user-defined functions (with multiple inputs and/or multiple outputs), writing functions (function main, function files), plotting multiple data series ENGR 1221 Note: Present results using fprintf()and comment your code throughout. Write a function that will compute the volume and surface area of a rectangular prism when provided with the object's 3 numerical dimensions. In other words, the function should be given three inputs (height, width and depth) and return two outputs (the volume and surface area, in that order). Show the following test cases: 1. a. height: 5 width:3 depth: 2 b. heignt:1 width:8 depth:4 c. height: 2 width:2 depth:10 The script should call the function 3 times and store the results of the three test cases in two row vectors called vol and sa. Function specifications Input arguments: length, width, height- all scalars. (Order does not matter) Output arguments: volume, area - both scalars. (Must be in this order) OPTIONAL: If you prefer, you can write the function such that the input and output arguments are arrays; in that case, only one call to the function is necessary. 2. Write a user-defined function (not an anonymous function) for the following math function: y(x) = 0.9x"e-0.1x-15x25x The function should accept x as its input and it should return y. Write the function such thatx can be a vector. a. Use the function to calculate y(-2) and y(4) b. Use the function to make a plot of y(x) for -3 3x s5 (use linspace with 100 values for x)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started