Question
The following below is a heart rate data for a set of patients. They measure heart rates of a set of patients while at rest,
The following below is a heart rate data for a set of patients. They measure heart rates of a set of patients while at rest, then weeks later measure the same set of patients again at rest. The trial period may have involved exercise, dieting, or medication. They have asked us to perform some basic analysis on the data. The data comes to us in 2 separate text files. Each text file contains N > 0 heart rates, one per line. The first line of each file represents patient #1, the second line of each file represents patient #2, and so on. Here are the files trial1-start.txt and trial1-end.txt:
Patient # trial1-start.txt trial1-end.txt
1 78 78
2 82 81
3 78 73
4 91 93
5 73 73
In this dataset, the heart rates of patients 2 and 3 have gone down, the heart rate of patient 4 has gone up, and the remaining patients (1 and 5) saw no change in their heart rates. Since the # of patients whose heart rate dropped (2) is greater than the # of patients whose heart rate went up (1), we say that the heart rates are trending downward: '-'. The percentage of patients whose heart rate when down is 40.0 (i.e. 2/5). The max change downward was -5, and the patient with the max change downward was #3.
Your assignment is to use MATLAB write a function AnalyzeHRs(file1, file2) that loads the heart rate data from 2 files (denoting before and after), and computes the trend, percentage of patients who saw this trend, and the max change in this trend:
function [Trend, Percentage, MaxChange] = AnalyzeHRs(file1, file2)
.
.
end
For example, given the input files shown earlier, calling from the command window like this:
[Trend, Percentage, MaxChange] = AnalyzeHRs('trial1-start.txt', 'trial1-end.txt') would return the following results:
Trend: '-'
Percentage: 40.0
MaxChange: -5
The function you have to write returns 3 values. The Trend is a single character: -, +, or =. If the # of patients whose heart rates dropped is > the # of patients whose heart rates went up, then the trend is downward: -. If the opposite occurred --- i.e. more heart rates went up than down --- then the trend is +. If the # of heart rates that dropped = the # of heart rates that went up, then the trend is =. Youll need to use if-then-else statements.
If the trend is down, then compute the Percentage of patients whose heart rate dropped. Also compute the MaxChange --- i.e. the largest drop in heart rate, which will be a negative number (e.g. -5). If the trend is up, then compute the Percentage of patients whose heart rate rose. Also compute the MaxChange --- i.e. the largest drop in heart rate, which will be a positive number. If the trend is equal (=), then compute the Percentage of patients whose heart rate remained the same. Return 0 for MaxChange.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started