MATLAB: Reverse order in column;flipud ain’t giving me that.

arrays

I'm trying to write a code that put some random input integers on two columns,one in order and the other in reverse order.Here's what I did: n = input('Enter the number of integers: ');
for index = 1:n
A = input('\n Enter your integer: ');
I(index) = A;
K(index) = flipud(A);
end
fprintf('\t index \t F \t R \n');
fprintf('\t ——\t—–\t—-\n');
for i = 1:n;
fprintf('\t %i \t %i \t %i \n',i, I(i),K(i));
end
but I'm not getting the reverse order.For 2 random inputs 5 and 6,here's what I'm getting:
index F R
------ ----- ----
1 5 5
2 6 6
I wanna get 6,5 respectively on the R column.

Best Answer

Try to put outside the first loop:
K = fliplr(I);
Related Question