Email: [email protected]

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/How to arrange elements in one array to match the position of elements in a second array?

How to arrange elements in one array to match the position of elements in a second array?

PuTI / 2025-04-01
How to arrange elements in one array to match the position of elements in a second array?
Matlab News

If I have two arrays A and B as displayed below, how can I rearrange B such that a new boolean array Ba which corresponds to the values of array B can be resorted according to the values of array A instead?
For example, if I have:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
B =
1 2 2 2 3 3 4 4 5 5
2 1 1 2 0 1 0 1 0 1
30 18 25 25 -1 23 -1 30 -1 22
Ba =
0 0 1 0 1 0 0 0 0 0
Note that array B is simply the sorted version of array A according to the first row in an ascended order. It is resorted twice according to the second row in an ascended order for the values in row 1 that equal one another (e.g., if there are multiples elements equal to 3 in row 1, then the array will sort by the second row instead, so if the second row has values 3 3 3 3 3; 2 6 3 9 1, it will then be sorted to 3 3 3 3 3; 1 2 3 6 9)
I only mentioned this in case reverse sorting might work easier than entirely rearranging the position of the array.
I want to rearrange array B and Ba such that it corresponds to the positioning of array A.
So the new arrays would look like this:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
Aa =
0 0 0 0 0 0 0 1 1 0
The new array would essentially match A, and the array Aa is the same array Ba but now rearranged so that it follows the arrangement of A rather than B.
I am not entirely sure how to write the MATLAB code to accomplish this. All help is appreciated!If I have two arrays A and B as displayed below, how can I rearrange B such that a new boolean array Ba which corresponds to the values of array B can be resorted according to the values of array A instead?
For example, if I have:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
B =
1 2 2 2 3 3 4 4 5 5
2 1 1 2 0 1 0 1 0 1
30 18 25 25 -1 23 -1 30 -1 22
Ba =
0 0 1 0 1 0 0 0 0 0
Note that array B is simply the sorted version of array A according to the first row in an ascended order. It is resorted twice according to the second row in an ascended order for the values in row 1 that equal one another (e.g., if there are multiples elements equal to 3 in row 1, then the array will sort by the second row instead, so if the second row has values 3 3 3 3 3; 2 6 3 9 1, it will then be sorted to 3 3 3 3 3; 1 2 3 6 9)
I only mentioned this in case reverse sorting might work easier than entirely rearranging the position of the array.
I want to rearrange array B and Ba such that it corresponds to the positioning of array A.
So the new arrays would look like this:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
Aa =
0 0 0 0 0 0 0 1 1 0
The new array would essentially match A, and the array Aa is the same array Ba but now rearranged so that it follows the arrangement of A rather than B.
I am not entirely sure how to write the MATLAB code to accomplish this. All help is appreciated! If I have two arrays A and B as displayed below, how can I rearrange B such that a new boolean array Ba which corresponds to the values of array B can be resorted according to the values of array A instead?
For example, if I have:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
B =
1 2 2 2 3 3 4 4 5 5
2 1 1 2 0 1 0 1 0 1
30 18 25 25 -1 23 -1 30 -1 22
Ba =
0 0 1 0 1 0 0 0 0 0
Note that array B is simply the sorted version of array A according to the first row in an ascended order. It is resorted twice according to the second row in an ascended order for the values in row 1 that equal one another (e.g., if there are multiples elements equal to 3 in row 1, then the array will sort by the second row instead, so if the second row has values 3 3 3 3 3; 2 6 3 9 1, it will then be sorted to 3 3 3 3 3; 1 2 3 6 9)
I only mentioned this in case reverse sorting might work easier than entirely rearranging the position of the array.
I want to rearrange array B and Ba such that it corresponds to the positioning of array A.
So the new arrays would look like this:
A =
1 5 3 2 4 4 2 2 3 5
2 1 1 2 0 1 1 1 0 0
30 22 23 25 -1 30 18 25 -1 -1
Aa =
0 0 0 0 0 0 0 1 1 0
The new array would essentially match A, and the array Aa is the same array Ba but now rearranged so that it follows the arrangement of A rather than B.
I am not entirely sure how to write the MATLAB code to accomplish this. All help is appreciated! array, sort MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Generate ST code from a look-up table with CONSTANT attribute
2025-05-22

Generate ST code from a look-up table with CONSTANT attribute

“no healthy upstream” error when trying to access My Account
2025-05-22

“no healthy upstream” error when trying to access My Account

MATLAB Answers is provisionally back?
2025-05-21

MATLAB Answers is provisionally back?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: [email protected]
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss