Homework 7 For each of the problems in this homework assignment, write a separat
ID: 3704398 • Letter: H
Question
Homework 7 For each of the problems in this homework assignment, write a separate MATLAB m-file. The name of each m-file must be exactly as specified in the corresponding problem statement. Submit your m-files by uploading to Canvas before the due date A p-file (an encrypted script file) for each of these problems is available on the Modules page of the course website. You can download these files and run them from the command line to see how your code should behave. Make the behavior of your code match that of the p-files For each of these problems in this assignment, you may want to create a separate m-file to use as a test bench. In these test bench m-files, you can define the vector or matrix, x, and call your m-file that operates on that vector or matrix. You MAY NOT use the following built in MATLAB functions: min.m, max.m, find.m, sort.m 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). 2) Filename: MAE1090 HW72.m Write an m-file that determines the row and column indices for all non-zero elements in a matrix, x. Row indices should be stored to the variable i, and column indices should be stored to the variable j.Explanation / Answer
%We are supposed to 1 question at a time, i have done the first 2, please ask 3rd again %Answer 1 %MAE1090_HW_1.m y=x(1); for i =1:length(x) if x(i)>y y=x(i); end end %%%%%%%%%%%%% %%Answer2 %MAE1090_HW7_2.m index=1; for k=1:size(x,1) for l=1:size(x,2) if x(k,l)~=0 i(index)=k; j(index)=l; index=index+1; end end end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.