Separate values from one column
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rita Barnabé
el 1 de Nov. de 2021
Hi
In this matrix I have 5 groups of values that I want to join.
Here is part of column:
26380
26381
26382
327207
327208
327209
327210
I want that the 3 first numbers to stay in one matrix and the rest in others.
With more cases of this
for n = 1:(length(newData)-1)
if ( newData(n+1,1)) == ( newData(n,1) + 1 )
line0(n+1) = n;
else if ( newData(n+1,1)) ~= ( newData(n,1) + 1 )
line1(n+1) = n+1;
end
end
I tried like this.
0 comentarios
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 2 de Nov. de 2021
Editada: Image Analyst
el 2 de Nov. de 2021
To group a vector of data into 5 different groups based on their values you can use kmeans() (in the Statistics and Machine Learning Toolbox):
v = [...
26380
26381
26382
327207
327208
327209
327210
222111
222133
222144
222124
111111
111141
111151
121245]
bar(v);
grid on;
indexes = kmeans(v, 5) % Cluster into 5 groups.
indexes is a vector that says what group each of your data values most likely belongs to.
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!