How to find rearrange these values in a new row and column?

1 view (last 30 days)
For example: I have the following array of data.
column 1 column 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
I would like to make a new array of data sets with
column 1 column 2
2 3
4 5
5 6
8 9
What would be the best command to rearrange the matrix?

Accepted Answer

Star Strider
Star Strider on 15 Feb 2019
One approach:
A = [1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9];
L = ismember(A(:,1), [2 4 5 8]);
B = A(L,:)
produces:
B =
2 3
4 5
5 6
8 9

More Answers (1)

madhan ravi
madhan ravi on 15 Feb 2019
newmatrix = matrix([2 4 5 8],:)
  4 Comments
madhan ravi
madhan ravi on 15 Feb 2019
Could you attach your file? and please explain what you want to do.
Mohammad Danial Bin Kamarul Zaman
I managed to solve the problem. Thank you soo much for your consideration. If you don't mind, I have another question that I would like to ask. Feel free to have a look at the link below:
Please accept my apologies for asking a lot of questions, i'm still new to MATLAB and eager to learn more about it.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!