Structs Help on indexing

1 次查看(过去 30 天)
Hassan Hijazi
Hassan Hijazi 2020-12-8
I have a struct with 7 feilds called climate.info
one of the feilds is City, and withing this feild there are hundreds of cities and the climate at certain times.
Therefore there are hundreds of entries of the same city at different times.
Is it possible to get the values of all the times of only that one specific city.
  2 个评论
Hassan Hijazi
Hassan Hijazi 2020-12-8
This is an example of the struct, and I want all the data values that are only for the city of abidjan
Walter Roberson
Walter Roberson 2020-12-8
Is climate.info.City a struct array ("hundreds of entries") that has fields that give the city name and fields that give the climate information ?

请先登录,再进行评论。

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-12-8
Try something like this
city_name = 'Abidjan';
idx = contains({climate.info.name}, city_name);
city_data = climate.info(idx)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by