Question

1) Filename: MAE1090_HW7_1.m Write an m-file that determines the maximum value in a vector, x, and...

1) Filename: MAE1090_HW7_1.m Write an m-file that determines the maximum value in a vector, x, and stores that maximum value as the variable y. Your m-file should work for both row and column vectors. For the purpose of testing and grading your m-file:

 DO NOT issue a clear command at the start of your m-file

 DO NOT define the vector x within your m-file. That vector should exist in the workspace prior to executing your m-file.

 Do not display y. This will be done by the script the grader uses to test your m-file.

 Variable names (x and y) must be exactly as specified (lower case).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MatLab Code

x + MAE1090_HW_7_1. m 1- y = x(1); WN for i= 2: length(x) if x(1) >y y = x(1); end end

Sample Output

>> X = (2,12.5, 54, 32,0.5, 67, 43, 51, 66]; >> MAE1090_HW_7_1 >> y >> x = [2,12.5,14,59,55,6,43,1,9,19]; >> MAE1090_HW_7_1

Add a comment
Know the answer?
Add Answer to:
1) Filename: MAE1090_HW7_1.m Write an m-file that determines the maximum value in a vector, x, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 9 Write a MATLAB command that stores the maximum value in the row vector x...

    Question 9 Write a MATLAB command that stores the maximum value in the row vector x and their indices in the row vector k for matrix A.

  • In matlab, I keep getting the same issue for this problem can someone help? "myrowproduct.m" >> Filename...

    In matlab, I keep getting the same issue for this problem can someone help? "myrowproduct.m" >> Filename myrowproduct (A,x) Undefined function or variable 'Filename' Did you mean: mfilename : myrowproduct (A, x) Undefined function or variable 'myrowproduct' function y = myrowproduct(A,x); function y my rowp roduct (A, x); Error: Function definition not supported in this context. Create functions in code file. (, 2,,)T 4. The product y Ax of an m x n matrix A times a vector x= can...

  • provide a python script please For the following vectors and matrices, using the NumPy library, write...

    provide a python script please For the following vectors and matrices, using the NumPy library, write a script file that determines the solution for x given by the equation x-(A AT)b-Cd where AT denotes the transpose of A 1 2 3 4 16 12 8 4 A-2 4 6 8 3 6 9 12 4 8 12 16 C-12 9 6 3 8 6 4 2 4 3 2 1 4 The output to the command terminal prompt within Spyder...

  • A through G please Obviously the quadrant that a vector is in determines the sian of...

    A through G please Obviously the quadrant that a vector is in determines the sian of the x and y component vectors Trigonometry and Vectors Given a vector, you can now draw they and component vectors. The sum of vectors x and y describe the The advantage is that math on the vandlor exactly. Again, any math done with the component vectors will be as valid as with the original vector. and minus signs instead of degrees Best antage is...

  • Let open a file and write to it: x = rand (8, 1); fileID = forpend('myfile.file.txt',...

    Let open a file and write to it: x = rand (8, 1); fileID = forpend('myfile.file.txt', w);% will create the file fprintf(fileID, '%4.4f\n', x); % Write to fileID felose(fileID); % Go to your workspace, look for myfile txt and open it. What do you see? How to read data from an open text file into a column vector A? Use fscanf as: A = fscanf(fileIDformatSpec) x = 5+ rand(10, 1); fileID = fopen (myfile.txt', r);% will create the file fprintf(fileID',...

  • For this project, each part will be in its oun matlab script. You will be uploading a total 3 m f...

    For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...

  • S.A vector IS givell by [5, 17,-3, 8, 0,-7, 12, 15, 20,-6, 6, 4,-7, 16]. Write...

    S.A vector IS givell by [5, 17,-3, 8, 0,-7, 12, 15, 20,-6, 6, 4,-7, 16]. Write a program as a 3 or 5, and, raises to the power of 3 the elements that are script tile that doubles the elements that are positive and are divisible by negative but greater than -5. following values. The value of each element in the first row is the number of the 6. Write a program in a script file that creates an matrix...

  • PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions...

    PLEASE HELP, MATLAB, answers are very appreciated need to study pl 2. Write two m-file functions that will allow you to compare mortgages cakculations for the monthly payment and compare mortgage with different loan values. The monthly payment M, is calculated using 1-2)1 Where Pis the principal loan amount, r is the interest rate (in decimal form not percent form), and y is the number of years of the loan. Create an m-file function called "mortgage_a.m" that will serve as...

  • Create a function m-file for the following expression which has two inputs X and Y. Call...

    Create a function m-file for the following expression which has two inputs X and Y. Call it “zoom”. Z = eVX2+Y2 /(X + Y) This function (zoom) can be in a separate script or as the last cell in your main m-file (which includes all of your solutions). Use Zoom to generate values for Z for X and Y values varying from 1 to 4 with an increment of 0.2. Also generate a table that includes all values for X...

  • Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8...

    Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8 9 10 11; 23 9 16 15 ;11 12 3 6; 1 2 8 9 ) ? = ( 2 21 7 15; 12 4 8 22; 23 9 5 13; 23 4 21 22) ℎ = (4 9 12 15) b. Add suitable lines of codes to the M-file to do the following. Each of the following points should be coded in only...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT