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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by