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

1 回表示 (過去 30 日間)
Wesser
Wesser 2020 年 12 月 7 日
回答済み: Stephan 2020 年 12 月 8 日
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!

回答 (1 件)

Stephan
Stephan 2020 年 12 月 8 日
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.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by