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

Construct a row array countValues with elements 1 to endValue, using the double

ID: 3887950 • Letter: C

Question

Construct a row array countValues with elements 1 to endValue, using the double colon operator. Transpose counfValues to result in a column array. Your Function Save C Reset MATLAB Documentation 1 function countvalues -CreateArray(endvalue) 21% endvalue : Ending value of countvalues % construct a row array countvalues with elements 1 to endvalue, % using the double colon operator countvalues 1; % Transpose countvalues to result in a column array 18 11 end Code to call your function C Reset 1CreateArray (3) Run Function Assessment Submit Check if CreateArray(3) returns [1;2;3 Check if CreateArray(8) returns [1;2;3;4;5; 6;7;8]

Explanation / Answer

CreateArray.m file

function countValues = CreateArray(endValue)
% : operator to construct an array
countValues = 1:endValue;
%transpose array
countValues = countValues.';
end

main.m file

CreateArray(3)
CreateArray(8)
% sample output
% ans =
%
% 1
% 2
% 3

%ans =
%
% 1
% 2
% 3
% 4
% 5
% 6
% 7
% 8