필터 지우기
필터 지우기

Sorting a matrix in percentiles

조회 수: 4 (최근 30일)
Andreas S
Andreas S 2020년 10월 13일
댓글: Andreas S 2020년 10월 14일
Good afternoon! I need your help as im new in matlab about solving my following issue:
I have a matrix ret [420x500]
I want to separate this matrix in 10 matrices of [420x50] each. Is there any code than can generate 10 different matrices of same size from the matrix ret[420x500]?
I need 10 equally sized matrices (the breakpoints should be the 10th, 20th, 30th,... , 90th percentiles). I.e., 10 matrices from a given matrix ret.
Thank you in advance!!!

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 13일
Use mat2cell()
M; % 420x500 matrix
M_parts = mat2cell(M, 420, 50*ones(1,10));
M_parts is a cell array. You can access it like this
M_parts{1}; % 1st 420x50 matrix
M_parts{2}; % 2nd 420x50 matrix
..
..
M_parts{10}; % 10th 420x50 matrix
  댓글 수: 7
Ameer Hamza
Ameer Hamza 2020년 10월 14일
Following sort column of ret from smalles to largest
[~, idx] = sort(mean(ret));
ret_sorted = ret(:, idx);
Andreas S
Andreas S 2020년 10월 14일
Thank you very much for all of your help. I appreciate it a lot!!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by