Reverse order in column;flipud ain't giving me that.

5 ビュー (過去 30 日間)
Mobasher Hossain
Mobasher Hossain 2015 年 3 月 14 日
回答済み: Image Analyst 2015 年 3 月 15 日
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.

採用された回答

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015 年 3 月 15 日
Try to put outside the first loop:
K = fliplr(I);
  2 件のコメント
Mobasher Hossain
Mobasher Hossain 2015 年 3 月 15 日
Thanks!!
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2015 年 3 月 15 日
You welcome!

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2015 年 3 月 15 日
Just because you're printing them on different lines does not turn a row vector, which is really what you have, into a column vector. It's still a row vector and therefore you should use fliplr() instead of flipud().

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by