How to keep rows including a specific name in structure and remove everything else within the structure?

6 visualizaciones (últimos 30 días)
Hi all,
I have a shape file (shp) that is read as a structure within MATLAB. It is a 2540x1 struc in the worksapce. One of its columns is character type. chr. I want to find a few names in it like 'Malta', keep the entire row that includes the Malta and then remove all other rows. Could you please teach me how to do that?
  1 comentario
Jan
Jan el 14 de Mzo. de 2021
Please post a short example of how your data look like. I do not understand "One of its columns is character type. chr." Structs do not have "columns".

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Mzo. de 2021
placenames = {YourStruct.PlaceNameField};
wanted_mask = ismember(placenames, {'Malta', 'Paraguey', 'Lake Wawa'});
selected_members = YourStruct(wanted_mask);

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by