how to sort table by row sub-string values?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
roudan
el 26 de Jul. de 2021
Comentada: Star Strider
el 26 de Jul. de 2021
Hi
I have a table like shown in the first picture. I'd like to sort this table using the last 2 characters of string, for example, 01A58, 02A58, 01A59, I'd like to sort it by 58 or 59. The 2nd pictures show the table I'd like to have . How to do it? I am looking at the command below and still not sure how to do it? Anyone can help me? Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/695819/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/695824/image.png)
0 comentarios
Respuesta aceptada
Star Strider
el 26 de Jul. de 2021
Try this —
wellname = {'01A58' rand; '01A59' rand; '01A62' rand; '01A63' rand; '01A66' rand; '01A58' rand; '01A59' rand}
wellnamesuffix = extractAfter(wellname(:,1),'A')
[wellsort,ix] = sort(wellnamesuffix)
wellname_sorted = wellname(ix,:)
.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!