From 0f1c29b7c59ad4499168e0f521cf0522d01cc594 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Fri, 9 Jul 2021 23:50:15 -0600 Subject: Added Functions and Scripts --- Functions/days/README.md | 11 +++++++++++ Functions/days/days.m | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Functions/days/README.md create mode 100644 Functions/days/days.m (limited to 'Functions/days') diff --git a/Functions/days/README.md b/Functions/days/README.md new file mode 100644 index 0000000..8a11db2 --- /dev/null +++ b/Functions/days/README.md @@ -0,0 +1,11 @@ +#days.m +Function to count the total days elapsed in a year according to a given date. +The syntax of the function is `days(, , )` where `months` is a integer (1-12). `days` is an integer (1-31) and `leap` + +## Input +months - month number (1-12). Example: `8` represents August. +days - day number of the month. +leap - indicates if the year is a leapyear or a regular year. `0` for regular and `1` for leap year. + +## Output +`nd` - number of days elapsed in the year. \ No newline at end of file diff --git a/Functions/days/days.m b/Functions/days/days.m new file mode 100644 index 0000000..87163b7 --- /dev/null +++ b/Functions/days/days.m @@ -0,0 +1,22 @@ +function nd = days(mo, da, leap) +%days - Counts days elapsed in the year. +% +% days(, , ) determines the days elapsed in a year +% based on the current date. This will include the current day. +% Months (1-12), +% Example: August 28, no leap year +% days(8,28,0) + +daysPeM=[0 31 59 90 120 151 181 212 243 273 304 334]; % cummulative days prior each month. + +nd = daysPeM(mo) + da; + +if leap == 1 & mo >= 3 + nd = nd + 1; +end +end + + +% MECH 105: Homework 4 - Part 1 +% Author: Christian Kolset +% Date: 5.21.21 \ No newline at end of file -- cgit v1.2.3