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

using matlab Create name function described below: Function name should be probl

ID: 3864839 • Letter: U

Question


using matlab

Create name function described below: Function name should be problem_2 function should accept 2 input arguments. The first input argument should be called iterations, the second input argument should be called the _number. Function should have 2 output arguments. The first should be called result, and the second should be called loop. The function body should do the following: It should create a for loop that will start at 1 and repeal "Iterations" times. That is the input argument called iterations, number inside. This number represents how many times the loop should repeat The variable that is used to Initialize your loop array (the thing that determines how many times your loop repeats) should be called loop counter. Each time the loop repeats, you should add the current value of your loop counter variable to whatever value is currently inside the input argument "the _number" and add this answer to whatever it in your output argument called result.

Explanation / Answer

Matlab code:-

Note:- The matleb code ie explained with comments followed by %

function [ result,loop_counter ] = problem_3(iterations,the_number) % function named problem_2 takes two input and two output arguments
for loop_counter=1:iterations % for loop to repeat for iterations number of times from 1 to iterations
the_number=the_number+loop_counter; % during each iteration the current value of loop_counter is added to the_number
end
result=the_number; % the value of the number is stored in result
end