Applying a function only to certain rows in a table, marked by the start of the name.

3 visualizaciones (últimos 30 días)
Hi and Hello,
I am currently working on a big set of data that is saved in a table.
The First collum is the Name of the Individual rows like "AB12_345678", AC12_345678
The rest of the collums contain different values. (doubles and numbers)
I am trying to figure out how to apply a function like mean or max only to those rows, thats name start with e.g "AB1".
I had no success with substrings, startsWith or rowfunc.
I am truly lost on how to do this since i want to avoid selecting the data by hand and running the code like 75 times.
Any and all help would be appreaciated.
Thanks in advance!

Respuesta aceptada

Saurabh
Saurabh el 6 de Jun. de 2023
you can use the startsWith function from the Text Analytics Toolbox to select the rows of a table whose name starts with a certain keyword.
And then accordingly You can access the rest of the values if you have the idices of the Table, thats name start with e.g "AB1".
Let me Know if this works.
startStr = "AB1";
idx = startsWith(string(file_name.PropertyName), startStr);
  2 comentarios
VeHe
VeHe el 6 de Jun. de 2023
Hi Saurabh,
it returned which Rows contain the string, so it wasn't quiet what I needed
But I looked at startsWith again and got this
TAB1 = Table(startsWith(Table.Column,'AB1'),:);
The codeline does create another table which might not be the most elegant way to do this, but like this I can apply the functions i need to the subsets
Thank you for your time and input!
Saurabh
Saurabh el 6 de Jun. de 2023
You are Welcome, if possible can you mark upvote/accept the solution.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by