# mjuliandate

Modified Julian date calculator

## Syntax

`mjd = mjuliandate(v)mjd = mjuliandate(s,f)mjd = mjuliandate(y,mo,d)mjd = mjuliandate([y,mo,d])mjd = mjuliandate(y,mo,d,h,mi,s)mjd = mjuliandate([y,mo,d,h,mi,s])`

## Description

`mjd = mjuliandate(v)` converts one or more date vectors, `v`, into modified Julian date, `mjd`. Input `v` can be an `m`-by-6 or `m`-by-3 matrix containing `m` full or partial date vectors, respectively. `mjuliandate` returns a column vector of `m` modified Julian dates. Modified Julian dates begin at midnight rather than noon, and the first two digits of its corresponding Julian date are removed.

A date vector contains six elements, specifying year, month, day, hour, minute, and second. A partial date vector has three elements, specifying year, month, and day. Each element of `v` must be a positive double-precision number.

`mjd = mjuliandate(s,f)` converts one or more dates, `s`, into modified Julian date, `mjd`, using format `f`. `s` can be a character array, where each row corresponds to one date character vector, or a one-dimensional cell array of character vectors. `mjuliandate` returns a column vector of `m` modified Julian dates, where `m` is the number of character vectors in `s`.

All of the dates in `s` must have the same format `f`, composed of the same date format symbols as the `datestr` function. `mjuliandate` does not accept formats containing the letter `Q`.

If a format does not contain enough information to compute a date number, then:

• Hours, minutes, and seconds default to 0.

• Days default to 1.

• Months default to January.

• Years default to the current year.

Dates with two-character years are interpreted to be within 100 years of the current year.

`mjd = mjuliandate(y,mo,d)` and `mjd = mjuliandate([y,mo,d])` return the decimal year for corresponding elements of the `y,mo,d` (year,month,day) arrays. Specify `y`, `mo`, and `d` as one-dimensional arrays of the same length or scalar values.

`mjd = mjuliandate(y,mo,d,h,mi,s)` and `mjd = mjuliandate([y,mo,d,h,mi,s])` return the modified Julian dates for corresponding elements of the `y,mo,d,h,mi,s` (year,month,day,hour,minute,second) arrays. Specify the six arguments as one-dimensional arrays of the same length or scalar values.

## Examples

Calculate the modified Julian date for May 24, 2005:

`mjd = mjuliandate('24-May-2005','dd-mmm-yyyy')`
```mjd = 53514```

Calculate the modified Julian date for December 19, 2006:

`mjd = mjuliandate(2006,12,19)`
```mjd = 54088```

Calculate the modified Julian date for October 10, 2004, at 12:21:00 p.m.:

```mjd = mjuliandate(2004,10,10,12,21,0) ```
```mjd = 5.3289e+004```

## Assumptions and Limitations

This function is valid for all common era (CE) dates in the Gregorian calendar.

The calculation of modified Julian date does not take into account leap seconds.

Get trial now