I am in Introduction to MATLAB Programming and I don\'t know how to solve this p
ID: 3787297 • Letter: I
Question
I am in Introduction to MATLAB Programming and I don't know how to solve this problem. Please explain legibly on how to construct the code & don't give the help section from MATLAB. I tried reading it, and I couldn't get it. Thanks!
Write a function called flip_it that has one input argument, a row vector v, and one output
argument, a row vector w that is of the same length as v. The vector w contains all the elements of
v, but in the exact opposite order. For example, is v is equal to [1 2 3] then w must be equal to
[3 2 1]. You are not allowed to use the built-in function flip.
Explanation / Answer
function [x] = flip_it(arg)
j = 1;
for i = length(arg) : -1 : 1
x(j) = arg(i);
j = j+1;
end
disp x
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.