ACrWVE 2.3.3: Double colon operator: Counting down. This tool is provided by a t
ID: 3888240 • Letter: A
Question
ACrWVE 2.3.3: Double colon operator: Counting down. This tool is provided by a third party Your activity is aways recorded but you may need to refresh the page to fill in the banner Double colon operator: Counting down Construct a row array countValues from startValue to endValue, elements decremented by -2 end Ex: lf startvalue is 10 and end alue iso,courtValues should be[10, 8, 6, 4, 2, 01. Your Function a Save C Reset MATLAB Documentation 1: function countValues = CreateArray (startValue, endValue) 2 s startVatue: Starting value of array % endValue: Ending value of array % construct a row array countvalues from startvalue 6 to endValue, elements decremented by -2 countValues = 0; L9 end Code to call your function C Reset 1 CreateArray (10, 0)Explanation / Answer
% function that takes 2 parameters
function countValues = CreateArray(startValue, endValue)
% initializing index to 1
ind = 1;
% as longs as start value is greater than end value
% will append it to array and reduce stat value by 2
while (startValue>=endValue)
countValues(ind) = startValue;
ind = ind+1;
startValue = startValue -2;
end
end
% sample run
disp(CreateArray(10,0));
Sample Output
10 8 6 4 2 0
% function that takes 2 parameters
function countValues = CreateArray(startValue, endValue)
% initializing index to 1
ind = 1;
% as longs as start value is greater than end value
% will append it to array and reduce stat value by 2
while (startValue>=endValue)
countValues(ind) = startValue;
ind = ind+1;
startValue = startValue -2;
end
end
% sample run
disp(CreateArray(10,0));
Sample Output
10 8 6 4 2 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.