How to cite only part of a vector in an equation?

1 vue (au cours des 30 derniers jours)
Wesser
Wesser le 7 Déc 2020
Hi,
I am working on a health study. I have the daily contaminant levels in grinking water, for a month long period, for three different communities. I am trying to tabulate people's exposure based on how long they drank the water. So, if JaneDoe lived in Town A from 1/1/12-1/5/12 and then lived in Town B from 1/6/12-1/31/12, her level of exposure would be....
The question is how do I cite only part of a vector based on a date range? This is a population study of several thousand people so I can't manually call the date ranges for each participant in the study... The code would be something along the lines of:
if town=TownA,
then ....cite this part of TownA's contaminant vector, but on ly for the date range in wich JaneDoe lived there....the muchy part I don't know how to code:[
Thanks for any thoughts on this!

Réponses (1)

Stephan
Stephan le 8 Déc 2020
One possible way:
You could use findgroups in combination with splitapply. For example, a JaneDoe group would be a member of the corresponding group regardless of the cities in which they were staying, and a function can be applied to these group members so that it is comparatively easy to obtain this information.
An example for understanding can be found here: https://de.mathworks.com/help/matlab/ref/findgroups.html#buxwasl
Another possible way:
Try to tackle this with groupsummary which also allows to make calculations on grouped data.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by