Question: IN MATLAB Code in MATLAB, Write a function with the header: function [lindex] = myLindex(nRowsMat, nColsMat, r, c) which calculates the linear index of element

IN MATLAB

Code in MATLAB,

Write a function with the header: function [lindex] = myLindex(nRowsMat, nColsMat, r, c) which calculates the linear index of element A(r,c) ASSUMING HORIZONTAL DOMINANCE. For example, if myLindex(4, 4, 3, 2) would be 10. (Four elements per row, 2*4 + 2 = 10). Your function should include the following checks on input: If the user enters an r > the number of rows of A, myLindex should return -1; If the user enters a c > the number of cols of A, myLindex should return -2; Test Cases: >> Alindex = myLindex(4,4,2,2) Alindex = 6 >> Alindex = myLindex(17,14,15,13) Alindex = 209 >> Alindex = myLindex(17,14,25,13) Alindex = -1 >> Alindex = myLindex(17,14,15,23) Alindex = -2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!