Clear Filters
Clear Filters

How to swap columns of matrix zeros(2,n)

1 view (last 30 days)
Hello everyone
I'm working on one project which in need to swap all the columns of the matrix zeros(2,n) which i want to swap the first column with last column, second with second column from last, third column from third column from last and so on can anybody help me with it thank you.
  2 Comments
Jos (10584)
Jos (10584) on 22 Apr 2015
Eh ... swapping two columns filled with zeros has no net effect, or does it?
Star Strider
Star Strider on 22 Apr 2015
@Jos — As is the case with a lot of Questions here, I suspect this is a proxy for a different problem.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 22 Apr 2015
From your description, the fliplr function would work.

More Answers (1)

Joseph Cheng
Joseph Cheng on 22 Apr 2015
Edited: Joseph Cheng on 22 Apr 2015
well you can achieve this by
test = randi(10,2,10)
hfliptest = test(:,end:-1:1)
i cant remember if there is a built in function to do this. perhaps someone else knows but this should do it.
**edit oh there it is fliplr.
  1 Comment
amina shafanejad
amina shafanejad on 22 Apr 2015
thank you for your response and help i think it will help me

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!