Thread Subject: Plotting percentage of data points in within a given range

Subject: Plotting percentage of data points in within a given range

From: Sean Takai

Date: 23 Nov, 2009 00:35:23

Message: 1 of 3

 I have a set of data where each patient gets a row and each column is a measurement at a certain time. I'm wondering if there's function that will allow me to plot the percentage of patients whose measurement is within a given ratio of a specified baseline over time.

For example:


              | Time 1 | Time 2 | ... | ... | ...
Patient 1 30 35
Patient 2 32 33
Patient 3 25 30
Patient 4 35 40

I would like to know if there is a function or some elegant way to create a plot vs time of the percentage of the patients listed above that are within a given range. For example, a range 30 - 32 would show 50% of patients within range for Time 1 and 25% for Time 2.

Right now I'm thinking of creating some for loops that would check each patient's measurement and create another matrix of percentages at each time, but I just wanted to check here for another way possibly.

Thanks in advance for any help.

Subject: Plotting percentage of data points in within a given range

From: ImageAnalyst

Date: 23 Nov, 2009 01:55:25

Message: 2 of 3

Sean:
Sure. You could do it in one line but I've expanded it out and am
being very verbose so you can understand each step of the way and to
make it more flexible and general.

clc;
close all;
clear all;
numberOfPatients = 30;
numberOfMeasurements = 40;
% Make up some sample patient measurements.
patientData = 100 * rand(numberOfPatients, numberOfMeasurements)
lowThreshold = 30;
highThreshold = 50;
% Find out which measurements are in range.
inRange = (patientData >= lowThreshold) & (patientData <=
highThreshold)
% Calculate the mean
patientPercentageInRange = 100 * sum(inRange, 2) /
numberOfMeasurements
% Calculate some overall averages, just for fun.
meanOverall = mean(patientData(:))
meanPercentageInRange = mean(patientPercentageInRange)

Of course your for loop way will work also.

Subject: Plotting percentage of data points in within a given range

From: Sean Takai

Date: 23 Nov, 2009 05:47:03

Message: 3 of 3

Thanks for your help!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
range Sean Takai 22 Nov, 2009 19:39:06
plots Sean Takai 22 Nov, 2009 19:39:05
rssFeed for this Thread

Contact us at files@mathworks.com