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

What am I doing wrong or missing to get this as my result? I am trying to do a r

ID: 3810800 • Letter: W

Question

What am I doing wrong or missing to get this as my result?

I am trying to do a reverse column vector for Array 3. I keep getting this.

The first result is correct but how do I get that result.

6. Write a Matlab program using FOR loop that prints a given row or column vector in reverse. 3 Array [7 10:3; 11:4; 1:12:1 15:2]: %create reverse vector reverse vector zeros (0,length (Array 3), 1) for i 1: length (Array 3) reverse vector (i) Array 3 (length (Array3) (i 1)) end 1 disp (C'The original array was matt 2str (Array 3) disp (C' The reversed array was: mat2str (reverse vector)

Explanation / Answer

The Correct code for displaying the reversed array [2;15;12;1;4;11;3;10;5;7] is as follows.


Array3 = [7;5;10;3;11;4;1;12;15;2];
reverse_vector = zeros(length(Array3),1);
for i =1:length(Array3)
reverse_vector(i) = Array3(length(Array3)-(i-1));
end
disp(['the original array was:' mat2str(Array3)]);
disp(['the reversed array was:' mat2str(reverse_vector)]);
Array3 = [7;5;10;3;11;4;1;12;15;2];
reverse_vector = zeros(length(Array3),1);
for i =1:length(Array3)
reverse_vector(i) = Array3(length(Array3)-(i-1));
end
disp(['the original array was:' mat2str(Array3)]);
disp(['the reversed array was:' mat2str(reverse_vector)]);

Result of the above code is :

the original array was:7;5;10;3;11;4;1;12;15;2]                                                                                                                                     

the reversed array was:[2;15;12;1;4;11;3;10;5;7]  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote