필터 지우기
필터 지우기

How to divide this data ?

조회 수: 1 (최근 30일)
Muhammad Hafiz
Muhammad Hafiz 2018년 4월 13일
댓글: Muhammad Hafiz 2018년 4월 13일
I have this data :
rank = [18 9 15 17 2 10 13 14 20 5 11 7 8 6 4 19 3 16 1 12 21]
I want to divide data like this
rank a = [18 15 2 13 20 11 8 4 3 1 21] rank b = [9 17 10 14 5 7 6 19 16 12 x]
I want to select x = 18 or is possible select 21 position as x
  댓글 수: 2
Bob Thompson
Bob Thompson 2018년 4월 13일
So you want all even number elements (based on positioning, not value) in one array, and odd number elements in the other?
Muhammad Hafiz
Muhammad Hafiz 2018년 4월 13일
yes Bob, I want all even number in rank a and select rank b into odd number position, I already try this problem but still get some error, please help me to solve this problem

댓글을 달려면 로그인하십시오.

채택된 답변

Bob Thompson
Bob Thompson 2018년 4월 13일
The sorting is relatively easy with indexing.
rank = [18 9 15 17 2 10 13 14 20 5 11 7 8 6 4 19 3 16 1 12 21]
ranka = rank(1:2:end); % Pull odd numbers (starts at 1)
rankb = rank(2:2:end); % Pull even numbers (starts at 2)
I'm not sure what you mean about the selection of x =
  댓글 수: 1
Muhammad Hafiz
Muhammad Hafiz 2018년 4월 13일
thanks bob you really help me :D

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by