You are working for a company as an engineer and you arc giv

You are working for a company as an engineer and you arc given the task of modifying some MATLAB code. Unfortunately, the code is not commented as it was hastily written several years ago by an employee who has since left the company. After examining the code, you realize that you do not know what the built-in MATLAB function size does, so you type help size in the command window, which displays: If you were to run the following code in MATLAB, determine what the variable maximum would contain. Indicate clearly a single, simple change you could make to the code above to make it run significantly faster.

Solution

rows=3 and cols=3

iteration 1 (c=1)

maximum(1)=10

inner loop

if condition compares with (10,4,6)

so maximum(1)=4

iteration 2 (c=2)

maximum(2)=4

inner loop

if condition compares with (1,3,9)

so maximum(2)=1

iteration 3 (c=3)

maximum(3)=6

inner loop

if condition compares with (7,6,2)

so maximum(3)=2

Hence maximum=[4 1 2]

to make code shorter you can go for function \'MIN\' that return minimum value in each coloumn.

compare this with first column values.

 You are working for a company as an engineer and you arc given the task of modifying some MATLAB code. Unfortunately, the code is not commented as it was hasti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site