Practice using statistical tools and plots.
Become familiar with sleep diary data for the project.
Handle more realistic data.
Interpret data and draw conclusions.

Hand-in Requirements:
The lab3Script.m script containing your work for all parts.
The published script in the same directory.
A document with your analysis.

This laboratory examines your sleep patterns as recorded in your sleep diary.

Your sleep diary file contains the following fields in a structure called diary:

bedTimes - bed times in decimal-date format (vector)
dayCaffeine - daytime caffeine indicators (vector)
nightCaffeine - evening caffeine indicators (vector)
toSleepMinutes - number of minutes to fall asleep (vector)
useAlarm - alarm use indicators (vector)
wakeTimes - wakeup times in decimal-date format (vector)
lastName - your last name
firstName - your first name
gender - 'male' or 'female'
section - your section number (vector)
minutesNap - number of minutes of napping (vector)
minsAwake - number of times awakened each night (vector)
SSI - Stanford Sleepiness Scale (or Index)

Structures are used to keep variables in a group. To access your bedtimes, for example, you would use diary.bedTimes. If you wanted a separate variable for your bed times, you would do:

myBedTimes = diary.bedTimes;
If you did not do a sleep diary, you will have to make up some data, enter it into the Excel spreadsheet and run the test scripts.

The bedtimes and wake-up times use MATLAB's decimal date format. The date is a number representing the offset from 0:00 of a particular reference day. The integer part of this value represents the day and the fractional part represents the fraction of 24 hours represented by the hour and minutes. Use the datestr function to convert the decimal value to a string for printing or viewing.

To properly handle times, you will convert time in decimal-date format to time in hours using the fractional part and ignoring the day part. Each time-hour will be relative to the day recorded in the sleep diary.

Example 1:The wake-up time 6:00 am on 9/23/2009 has the decimal date value of 734039.25. The 0.25 represents 6/24 fraction of a day. The time-hour would be 6.0

Example 2:The decimal date of 9/22/2009 at 9:00 pm is 734038.875. If the day of the recording was 9/23, 734038.875 - 734039 = -0.125 represents 3/24 hours before midnight of the previous day. The time-hour would be -3.0

Example 3:The decimal date of 9/23/2009 at 5:49 am is 734039.242361111. The fraction 0.242361111 can be calculated as (5 + 49/60)/24. The time-hr would be 5.817

Part I: Initial set up
Create a directory called lab3 in V:.
Change your MATLAB working directory to be this directory.
Copy your processed diary .mat into this directory.
Part II: Data analysis requirements:
In this project you should analyze your sleep characteristics using the statistical and graphical tools covered in class. Your script should calculate and output the following:
You should calculate and output the basic statistical indicators for your individual diary (maximum, minimum, mean, median, standard deviation, AAD and MAD) of:
Wake-up time-hours (relative to midnight on wakeup day)
Bed time-hours (relative to midnight on wakeup day)
Hours of sleep (wake times - bed times converted to hours)
Minutes to sleep
Minutes napping
Minutes awake during the night
Total daily sleep (hours of sleep + hours of napping - hours awake during the night - hours to fall asleep)
Your Stanford Sleepiness Scale (SSI)
Your output should be in tabular format (use %#.#f to line up the columns) with the names of the variables (e.g., wake-up time, etc.) in the left most column. Label the columns with the names of the indicators (e.g., Maximum, etc.).
You should calculate and output:
Percentage of days you woke up to an alarm
Percentage of days you used caffeine
Percentage of nights you used caffeine
Percentage of days that you took a nap
You should create the following graphs:
Four histograms describing the distributions of your bed times, wake-up times, hours of sleep, and total daily sleep.
A line graph (plot) that plots bed time-hours, wake time-hours, hours sleep, and total daily sleep vs time.
Two line graphs showing two data sets vs time on the same graph (plotyy or subplot). Note: the horizontal axis is the day number. Possible pairs to consider bed time-hours,vs hours of sleep, bed time-hours,vs wake time-hours, bed time-hours,vs total daily sleep, etc.
Three scatter plots with meaningful correlation values between two data sets. (Include the linear fit line, equation of the linear fit line and the correlation either as part of the legend or in the title.) Possible data to compare: bed time-hours,vs wake time-hours, bed time-hours vs hours of sleep, sleep hours vs nap minutes, nap minutes vs SSI, wake time-hours vs nap minutes, daily sleep hours vs SSI, etc.
Two errorbar graphs showing average wake-up time and hours of sleep by day of the week. Use standard deviation for the errorbars.
Note: You may find the handout Coding a best fit line useful if you would like to avoid manual editing of your graphs.
Part III: Publish the results
Publish your script by pushing the Publish icon. Make sure that your script is separated appropriately into cells and that each cell has a title indicating what is computed in that cell.

Make 3 observations (from the statistical indicators) in bullet point form.
Make 3 observations (from the graphs) in bullet point form. Refer to specific figures when making the observations.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

%function process()
%Process the diary.
load HillJustinmale
%% Extract the fields
bedTimes=diary.bedTimes; %double
dayCaffeine=diary.dayCaffeine; %logical
nightCaffeine= diary.nightCaffeine; %logical
toSleepMinutes=diary.toSleepMinutes; %double
useAlarm= diary.useAlarm; %logical
wakeTimes=diary.wakeTimes; %double
minutesNap=diary.minutesNap; %double
timesAwake=diary.timesAwake; %double
%% Process wakeTimes
fwakeTimes=24*(wakeTimes-floor(wakeTimes)); %in 24 hours

%% Process bedTimes
fbedTimes=24*(bedTimes-floor(bedTimes)); %in 24 hours
$33.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available MATLAB for Mathematics Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats