Split vector into array with different ranges

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].

Respuestas (1)

Dyuman Joshi
Dyuman Joshi el 12 de Mayo de 2021
Editada: Dyuman Joshi el 12 de Mayo de 2021
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 comentarios

Mine Tunç
Mine Tunç el 12 de Mayo de 2021
Actually I have tried this anwer but Iit did not work. But thank you for the answer
Dyuman Joshi
Dyuman Joshi el 12 de Mayo de 2021
What does your code look like? What are the values in a?
Mine Tunç
Mine Tunç el 12 de Mayo de 2021
The values are taken as input from the user and also I need to write it with a function
Dyuman Joshi
Dyuman Joshi el 12 de Mayo de 2021
Have you written any code? If yes, then show it. I'll be able to help better.
Mine Tunç
Mine Tunç el 20 de Mayo de 2021
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 el 20 de Mayo de 2021
So, do you still want help?

Iniciar sesión para comentar.

Categorías

Productos

Versión

R2021a

Preguntada:

el 12 de Mayo de 2021

Comentada:

el 20 de Mayo de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by