Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are working for a company as an engineer and you arc given the task of modif

ID: 2313368 • Letter: Y

Question

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.

Explanation / Answer

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.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote