Split vector into array with different ranges

조회 수: 3 (최근 30일)
Mine Tunç
Mine Tunç 2021년 5월 12일
댓글: Dyuman Joshi 2021년 5월 20일
Hey Guys! I am new to MATLAB and I could not solve this question. There is a lot of ways to do it but these are the this that I did not learn at all. Write a function that splits the elements of a vector into three arrays with different ranges: [0-10), [10-100) and [100,1000]. For instance, a=[ 22 9 65 814 165 3 ] wil become x=[9 3], y=[22 65] and z=[814 165].

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2021년 5월 12일
편집: Dyuman Joshi 2021년 5월 12일
a=[22 9 65 814 165 3];
x=a(a<10);
y=a(a>=10&a<100);
z=a(a>=100);
This is assuming that the numbers in x are in the range [0-1000]. For any other range, edit accordingly.
  댓글 수: 6
Mine Tunç
Mine Tunç 2021년 5월 20일
I wrote it but I delete all of them because it didn't work I can not do it it drives me mad, I know it is easy but...
Dyuman Joshi
Dyuman Joshi 2021년 5월 20일
So, do you still want help?

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by