Prev: event study
Next: Simulink accelerator problem
From: Sean Takai on 22 Nov 2009 19:35 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.
From: ImageAnalyst on 22 Nov 2009 20:55 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.
From: Sean Takai on 23 Nov 2009 00:47 Thanks for your help!
|
Pages: 1 Prev: event study Next: Simulink accelerator problem |