{"id":6957,"date":"2021-10-11T15:46:15","date_gmt":"2021-10-11T15:46:15","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/2-write-a-function-with-header-m-mymaxa-where-m-is-the-maximum\/"},"modified":"2021-10-11T15:46:15","modified_gmt":"2021-10-11T15:46:15","slug":"2-write-a-function-with-header-m-mymaxa-where-m-is-the-maximum","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/2-write-a-function-with-header-m-mymaxa-where-m-is-the-maximum\/","title":{"rendered":"2. write a function with header [m] = mymax(a) where m is the maximum"},"content":{"rendered":"<div>\n<p><strong><span>2. <\/span><\/strong><span>Write a function with header <\/span><span>[M] = myMax(A) <\/span><span>where <\/span><span>M <\/span><span>is the maximum (largest) value in<br \/><\/span><span>A<\/span><span>. Do not use the built-in MATLAB function <\/span><span>max<\/span><span>.<br \/><\/span><strong><span>3. <\/span><\/strong><span>Write a function with header <\/span><span>[M] = myNMax(A,N) <\/span><span>where <\/span><span>M <\/span><span>is an array consisting of the <\/span><span>N<br \/><\/span><span>largest elements of <\/span><span>A<\/span><span>. You may use MATLAB\u2019s <\/span><span>max <\/span><span>function. You may also assume that <\/span><span>N <\/span><span>is<br \/>less than the length of <\/span><span>M<\/span><span>, that <\/span><span>A <\/span><span>is a one-dimensional array with no duplicate entries, and that <\/span><span>N<br \/><\/span><span>is a strictly positive integer smaller than the length of <\/span><span>A<\/span><span>.<br \/>Test Case:<br \/><\/span><strong><span>4. <\/span><\/strong><span>Let <\/span><em><span>M <\/span><\/em><span>be a matrix of positive integers. Write a function with header <\/span><span>[Q] =<br \/>myTrigOddEven(M) <\/span><span>, where <\/span><em><span>Q<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>) <\/span><\/em><span>= <\/span><span>sin <\/span><em><span>(<\/span><\/em><em><span>M<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>)) <\/span><\/em><span>if <\/span><em><span>M<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>) <\/span><\/em><span>is even, and <\/span><em><span>Q<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>) <\/span><\/em><span>=<br \/><\/span><span>cos <\/span><em><span>(<\/span><\/em><em><span>M<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>)) <\/span><\/em><span>if <\/span><em><span>M<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>) <\/span><\/em><span>is odd.<br \/><\/span><strong><span>5. <\/span><\/strong><span>Let <\/span><em><span>P <\/span><\/em><span>be an <\/span><em><span>m <\/span><\/em><span>\u00d7 <\/span><em><span>p <\/span><\/em><span>matrix and <\/span><em><span>Q <\/span><\/em><span>be a <\/span><em><span>p <\/span><\/em><span>\u00d7 <\/span><em><span>n <\/span><\/em><span>matrix. As you will find later in this book,<br \/><\/span><em><span>M <\/span><\/em><span>= <\/span><em><span>P <\/span><\/em><span>\u00d7 <\/span><em><span>Q <\/span><\/em><span>is defined as <\/span><em><span>M<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>) <\/span><\/em><span>= <\/span><em><span>kp<\/span><\/em><span>=<\/span><span>1 <\/span><em><span>P<\/span><\/em><em><span>(<\/span><\/em><em><span>i<\/span><\/em><em><span>, <\/span><\/em><em><span>k<\/span><\/em><em><span>) <\/span><\/em><span>\u00b7 <\/span><em><span>Q<\/span><\/em><em><span>(<\/span><\/em><em><span>k<\/span><\/em><em><span>, <\/span><\/em><em><span>j<\/span><\/em><em><span>)<\/span><\/em><span>. Write a function with header<br \/><\/span><span>[M] = myMatMult(P,Q) <\/span><span>that uses for-loops to compute <\/span><span>M<\/span><span>, the matrix product of <\/span><span>P <\/span><span>and <\/span><span>Q<\/span><span>.<br \/>Hint: You may need up to three nested for-loops.<br \/>Test Cases:<br \/><\/span><strong><span>6. <\/span><\/strong><span>The interest, <\/span><em><span>i<\/span><\/em><span>, on a principle, <\/span><em><span>P<\/span><\/em><span>0<\/span><span>, is a payment for allowing the bank to use your money.<br \/>Compound interest is accumulated according to the formula <\/span><em><span>P<\/span><\/em><em><span>n <\/span><\/em><span>= <\/span><em><span>(<\/span><\/em><span>1 <\/span><span>+ <\/span><em><span>i<\/span><\/em><em><span>) <\/span><\/em><em><span>P<\/span><\/em><em><span>n<\/span><\/em><span>\u2212<\/span><span>1 <\/span><span>, where <\/span><em><span>n <\/span><\/em><span>is the<br \/>compounding period, usually in months or years. Write a function with header <\/span><span>[years] =<br \/>mySavingPlan(P0, i, goal) <\/span><span>where years is the number of years it will take <\/span><em><span>P<\/span><\/em><span>0 <\/span><span>to<br \/>become goal at <\/span><em><span>i<\/span><\/em><span>% interest compounded annually.<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>2. Write a function with header [M] = myMax(A) where M is the maximum (largest) value inA. Do not use the built-in MATLAB function max.3. Write a function with header [M] = myNMax(A,N) where M is an array consisting of the Nlargest elements of A. You may use MATLAB\u2019s max function. You may also assume [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-6957","post","type-post","status-publish","format-standard","hentry","category-homework-help"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/6957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=6957"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/6957\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=6957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=6957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=6957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}