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

CONVERT THIS MATLAB LANGUAGE TO WORK IN PYTHON function nexceed_array = exceed_c

ID: 668634 • Letter: C

Question

CONVERT THIS MATLAB LANGUAGE TO WORK IN PYTHON

function nexceed_array = exceed_consecutive(array, threshold)

is_consecutive = 0;

n = 0;

nexceed_array = [];

for i = 1:length(array)

    if array(i) > threshold

  

        n = n + 1;

    

        is_consecutive = 1;

    else

        if is_consecutive

          

            nexceed_array(end+1) = n;

          

            n = 0;

         

            is_consecutive = 0;

        end

    end

end

if array(end) > threshold

if length(nexceed_array) == 0

    nexceed_array = 0;

end

Explanation / Answer

Please find the converted code below

@mfunction("nexceed_array")
def exceed_consecutive(array=None, threshold=None):

is_consecutive = 0

n = 0

nexceed_array = mcat([])

for i in mslice[1:length(array)]:


if array(i) > threshold:

n = n + 1

is_consecutive = 1


else:

if is_consecutive:

nexceed_array(end + 1).lvalue = n

n = 0


is_consecutive = 0

end

end

end


if array(end) > threshold:


if length(nexceed_array) == 0:
nexceed_array = 0
end

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