How to split an array based on the maximum number?

조회 수: 1 (최근 30일)
Maaz Madha
Maaz Madha 2021년 2월 2일
답변: Rik 2021년 2월 2일
Hi
How can I split this array so that the 3000s would be in a different array and the 2000s would be in a different one. I know I can just use indexes to do it but I was wondering if there is a general method for it, so that no matter what the values are it would be able to sort it based on the most left handed number(so into 3,2,1) etc.

답변 (1개)

Rik
Rik 2021년 2월 2일
You can use the function below to find the first digit of positive values, which you can then use to group your data.
f=@(x)floor(x./(10.^floor(log10(x))));

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by