The MATLAB question: You should now be familiar with MATLAB's built-in max function. Without using the built-in
Fantastic news! We've Found the answer you've been seeking!
Question:
The MATLAB question:
Transcribed Image Text:
You should now be familiar with MATLAB's built-in "max" function. Without using the built-in max(), min() and sort() functions, write a function that takes vector as an input and returns the maximum value as well as the index at which the maximum value occurs. Your function should work with input vectors of any length. Your function header should be similar to the following: function [max_value, index] = mymax(x) Test your function for f(x)=x(¹/x) for values between 0 and 50 with a step size of 0.001. Check the maximum value and index using MATLAB's built-in max() function. Plot f(x) and mark the maximum point. Remember to include a legend. *Although not necessary for this task, think about how you would code this for a two-dimensional matrix by creating a function which finds the maximum value and its corresponding row and column. function [max_value, row, column] = mymax2(x) You should now be familiar with MATLAB's built-in "max" function. Without using the built-in max(), min() and sort() functions, write a function that takes vector as an input and returns the maximum value as well as the index at which the maximum value occurs. Your function should work with input vectors of any length. Your function header should be similar to the following: function [max_value, index] = mymax(x) Test your function for f(x)=x(¹/x) for values between 0 and 50 with a step size of 0.001. Check the maximum value and index using MATLAB's built-in max() function. Plot f(x) and mark the maximum point. Remember to include a legend. *Although not necessary for this task, think about how you would code this for a two-dimensional matrix by creating a function which finds the maximum value and its corresponding row and column. function [max_value, row, column] = mymax2(x)
Expert Answer:
Answer rating: 100% (QA)
ANSWER CODE mymax function maxvalueindexmymaxx maxva... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
array to work out the total heads and tails total_no_heads = sum(trials 1) total_no_tails = sum(trials == 0)
-
Jaco has 11 different pamphlets which he wishes to put in 4 mail boxes labelled A, B, C and D. In how many different ways may he put the pamphlets in the mail boxes in such a way that mail box D gets...
-
Use MATLAB to construct a matrix A by setting A = vander(1 : 6); A = A - diag(sum(A)) (a) By construction, the entries in each row of A should all add up to zero. To check this, set x = ones(6, l)...
-
The table below gives the marginal abatement costs of three polluting firms in an industry. The industry is regulated with an emission tax of $9. Emissions. (tons/week) 10 9 8 7 6 5 4 3 2 1 0...
-
Explain the reasons for hot tearing in castings.
-
What is shareholder wealth maximization?
-
The company is committed to ethical conduct and has no tolerance for fraud and unethical behavior. There are some concerns about abuses in your department. Do you know anything about the concerns I...
-
Following are the auditor's calculations of several key ratios for Cragston Star Products. The primary purpose of this information is to understand the client's business and assess the risk of...
-
How much energy does a male Jackson's widowbird of mass 45 g expend when jumping to a height of 1.0 m during its mating ritual? Neglect all losses due to air resistance
-
a. Prepare a UML class diagram with classes, associations, and multiplicities. b. Using the preceding information and the following attributes list, prepare a listing of the relational tables...
-
4. What will be the output of the program? (1 Marks) #include void main() { } int x=4, y, z; y=--x; z=X--; printf("Z=%d X=%d",x,y);
-
You are tasked with building a foam roller coaster similar to what we built in class. The roller coaster must have a loop and a hill, no second marble, and the first marble must stop within 1 1 ft ....
-
Consider using kNN density estimation to separate two equi-likely classes using l = 1 feature. You are given four training values, two for each class: X (1) [-2 1] X() = [35]. = Use k = 2 to classify...
-
Solve the following differential equation y' = 2xy, y(0)=2 4) Exactly (analytically) 5) Using the Runge-Kutta method 6) Plot both solutions in a single graph (using gnuplot, Excel, or any software of...
-
A 423.5-N force accelerates a go cart and its driver from 10.4 m/s to 17.9 m/s in 5.0 s. What is the mass of the go cart plus driver?
-
A woman drives a car from one city to another with different constant speeds along the trip. she drives at a speed of 9 0 . 0 9 0 . 0 km / / h for 2 0 . 0 2 0 . 0 min, makes a stop for 4 5 . 0 4 5 ....
-
Using a factory overhead allocation method such as the single plantwide factory overhead rate can cause product cost distortions. However, this method is less complicated and inexpensive to maintain....
-
In Problems, solve each system of equations. x + 2y + 3z = 5 y + 11z = 21 5y + 9z = 13
-
Determine the matrix representation of each of the following composite transformations. (a) A yaw of 90, followed by a pitch of 90 (b) A pitch of 90, followed by a yaw of 90J (c) A pitch of 45,...
-
Let A be the matrix given in Exercise 21. For each of your solutions x to Exercise 21(b), compute Ax and compare it to Pb.
-
Let aj be a nonzero column vector of an m x n matrix A. Is it possible for aj to be in N(AT)? Explain.
-
In 1984, the number of German marks required to buy one U.S. dollar was 1.80. In 1987, the U.S. dollar was worth 2.00 marks. In 1992, the dollar was worth 1.50 marks. In 1997, the dollar was again...
-
Todays spot rate is S 0 $ = $0.009057355. The 90-day forward rate is F 1 $ = $0.008772945. a. Calculate the forward premium on Japanese yen in basis points and as a percentage premium or discount...
-
Describe locational, triangular, and covered interest arbitrage.
Study smarter with the SolutionInn App