How to Swap Column according to odd/even numbers?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi everyone, I would like to arrange my column according to odd and even numbers. Example data is shown below, I want to arrange column 1(even numbers) while column2 (odd numbers). Can anyone help me on how to arrange / swap into the according column.
nPASS1 nPASS166
nPASS1 nPASS64
nPASS101 nPASS12
nPASS101 nPASS88
nPASS103 nPASS166
nPASS103 nPASS90
nPASS114 nPASS229
nPASS114 nPASS51
nPASS12 nPASS127
댓글 수: 4
James Tursa
2020년 11월 24일
How is this stored? Cell array of char strings? Array of strings? Or ...???
답변 (1개)
KSSV
2020년 11월 24일
This is basic in MATLAB. You should read about indexing an array.
Example:
A = rand (10.1); % array for demo
E = A (2: 2: end); % get even indices number
O = A (1: 2: end); % GEt odd indices numbersY
You may also have cell arrays. For cell arrays you need to use {} for indexing.
댓글 수: 2
KSSV
2020년 11월 24일
Let it be. If he is not satisfied, he will ask the question again. There is no harm right?
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!