Clear Filters
Clear Filters

Conditional histogram plotting help

7 views (last 30 days)
Wesser
Wesser on 14 Apr 2021
Commented: Wesser on 14 Apr 2021
Hi,
I'm trying to figure out how to plot only certain output data if certain conditions are met.
I have a 10000x207 matrix. Each column representing one of the 207 participants in a study, who were subject to 10k monte carlo (MC) iterations of a health analysis. I use the following to plot a histogram of all the MC iterations for all the participants:
figure
h = histogram(MCExpoStart);
xlabel('Start of PFHxS Exposure')
ylabel('Count')
title('Histogram of start of exposure for all study participants')
I'd like to then selectively plot participant data from this original matrix based on certain conditions being met in another matrix. For example, I have another matrix (98x207) that represents where the 207 participants lived over 98 sequential time intervals. This is a matrix made up of numbers 1 through 10, which represent 10 different municipalities. So for example, if a participant has a 1 at a given time, it means that the person lived in town X, but if there is a 2 at an interval the person lived in town Y, 3 = town Z, etc. I'd like to make a histogram of the original MCExpoStart data, but only for the people that lived in towns X and Y at any point in time. I imagine the code would be something like this, but this isn't working... Any suggestions out there? Many thanks in advance!!
figure
if (town(t,column)==1) && (town(t,column)==2) %t=time interval
h = histogram(MCExpoStart(i,column)); %i=monte carlo iteration, column=participant in study
xlabel('Start of PFAS Exposure')
ylabel('Count')
title('Histogram of start of exposure for all X and Y residents')
else
end
  4 Comments
Wesser
Wesser on 14 Apr 2021
Edited: Wesser on 14 Apr 2021
I had not heard of the "any" function yet. Thank you for the introduction to this. I'm not sure this works though?
town(t,column) looks like this, but much larger and with 4 towns respresented not 10 as in the real situation:
1 4 2 2 3 3 3
1 4 2 2 3 3 1
1 4 2 2 1 3 1
1 4 2 2 1 3 1
1 4 2 2 1 3 1
Each column is one of 7 participants (in this micro example), each row is a point in time.
1=town X
2=town Z
3=town Y
4=town Q
So I if any of the columns, at any point in time, has a 1 or 2 (ie. particiapant lived in towns X and/or Z), I want to plot a histogram of the coresponding column data from MCExpoStart(i,column). he participant in column 2 lived in town Q, so I don't care about thier MCExpoStart data and I don't want to include it in this histogram. So in this example plot the MCExpoStart data for colums 1, 3, 4, 5 and 7, but not 2 and 6.
Wesser
Wesser on 14 Apr 2021
Ok. This makes sense. Thank you for your help with this!

Sign in to comment.

Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!