Final answer:
The student is looking for a MATLAB function named 'revVec' to reverse a vector. A function is provided using a for-loop to populate a new vector with elements from the input vector in reverse order. Using this function will return a new reversed vector.
Step-by-step explanation:
The student is asking for the MATLAB code to write a function named revVec which takes a vector as an input and returns a modified vector that is reversed. To achieve this, a for-loop can be used to iterate over the vector in reverse order and construct the reversed vector. Below is an example of how such a function can be written in MATLAB:
function outputVec = revVec(inputVec)
n = length(inputVec);
outputVec = zeros(1, n);
for i = 1:n
outputVec(i) = inputVec(n - i + 1);
end
end
This code creates a new vector outputVec of the same size as inputVec and then uses a for-loop to fill outputVec with elements from inputVec in reverse order. After executing this function, for example, revVec([3 8 9 2]) will return [2 9 8 3].