155k views
4 votes
Construct a column array elevatorStops with values 2, 4, 5, 9, and 10 function elevatorStops = AddStops() % Construct a column array elevatorStops with values 2, 4, 5, 9, and 10 elevatorStops = [2]; end Code to call your function when you click Run AddStops()

User PiQuer
by
7.3k points

1 Answer

0 votes

Final answer:

The correct MATLAB code to create the column array 'elevatorStops' with values 2, 4, 5, 9, and 10 in a function named 'AddStops' is given. The semi-colon is used to ensure the creation of a column vector.

Step-by-step explanation:

The student is asking for help with writing a function in MATLAB, a programming environment often used for numerical computing. To construct a column array named elevatorStops with the values 2, 4, 5, 9, and 10, you need to modify the provided function so that it creates the desired array structure. Here is the corrected code:

function elevatorStops = AddStops()
% Construct a column array elevatorStops with values 2, 4, 5, 9, and 10
elevatorStops = [2; 4; 5; 9; 10];
end

Notice that the semi-colon (;) is used after each value to ensure that MATLAB creates a column vector rather than a row vector. Oncethe function is called with AddStops(), it returns the column array as defined.

User Mrgrechkinn
by
8.1k points