This MATLAB function transforms corresponding elements of the two-dimensional Cartesian coordinate arrays x and y into polar coordinates theta and rho. = cart2pol(x,y,z) transforms three-dimensional Cartesian coordinate arrays x, y, and z into cylindrical coordinates theta, rho, and z.
t
— Dates and times
array of datetime or duration values
Dates and times, specified as an array of datetime or duration values.
Data Types:
datetime
| duration
| calendarDuration
DateNumber
— Serial date number
array of positive double-precision numbers
Serial date number, specified as an array of positive double-precision numbers.
Example:
731878
Data Types:
double
DateString
— Text representing dates and times
character array | cell vector of character vectors | string vector
Text representing dates and times, specified as a character array where each row contains text representing one point in time, as a cell vector of character vectors, or as a string vector. All rows of a character array, or all elements of a cell vector or string vector, must have the same format.
Example:
'24-Oct-2003 12:45:07'
Example:
['19-Sep-2013';'20-Sep-2013';'21-Sep-2013']
Example:
{'15-Oct-2010' '20-Nov-2012'}
If the format used in the text is known, you should also specify
formatIn
. If you do not specify formatIn
, then DateString
must be in one of the following formats.Format of Text RepresentingDates and Times | Example |
---|---|
'dd-mmm-yyyy HH:MM:SS' | 01-Mar-2000 15:45:17 |
'dd-mmm-yyyy' | 01-Mar-2000 |
'mm/dd/yyyy' | 03/01/2000 |
'mm/dd/yy' | 03/01/00 |
'mm/dd' | 03/01 |
'mmm.dd,yyyy HH:MM:SS' | Mar.01,2000 15:45:17 |
'mmm.dd,yyyy' | Mar.01,2000 |
'yyyy-mm-dd HH:MM:SS' | 2000-03-01 15:45:17 |
'yyyy-mm-dd' | 2000-03-01 |
'yyyy/mm/dd' | 2000/03/01 |
'HH:MM:SS' | 15:45:17 |
'HH:MM:SS PM' | 3:45:17 PM |
'HH:MM' | 15:45 |
'HH:MM PM' | 3:45 PM |
Note
The symbolic identifiers describing date and time formats aredifferent from those that describe the display formats of
datetime
arrays.Certain formats might not contain enough information to convert text representations of dates and times. In those cases, hours, minutes, and seconds default to 0, days default to 1, months default to January, and years default to the current year.
datevec
and datenum
consider two-character years (e.g., '79'
) to fall within the 100-year range centered around the current year.When you do not specify
formatIn
, note thefollowing:- For the formats that specify the month as two digits(
mm
), the month value must not be greater than12. - However, for the format
'mm/dd/yy'
,if the first entry in the text is greater than 12 and the second entryis less than or equal to 12, thendatevec
considersthe text to be in'yy/mm/dd'
format.
formatIn
— Format of the input text representing dates and times
character vector | string scalar
Format of the input text representing dates and times, specified as a character vector or string scalar of symbolic identifiers.
Example:
'dddd, mmm dd, yyyy'
The following table shows symbolic identifiers that you can use to construct the
formatIn
character vector. You can include characters such as a hyphen, space, or colon to separate the fields.Note
The symbolic identifiers describing date and time formats are different from the identifiers that describe the display formats of
datetime
arrays.Symbolic Identifier | Description | Example |
---|---|---|
yyyy | Year in full | 1990 , 2002 |
yy | Year in two digits | 90 , 02 |
QQ | Quarter year using letter Q and onedigit | Q1 |
mmmm | Month using full name | March , December |
mmm | Month using first three letters | Mar , Dec |
mm | Month in two digits | 03 , 12 |
m | Month using capitalized first letter | M , D |
dddd | Day using full name | Monday , Tuesday |
ddd | Day using first three letters | Mon , Tue |
dd | Day in two digits | 05 , 20 |
d | Day using capitalized first letter | M , T |
HH | Hour in two digits (no leading zeroswhen symbolic identifier AM or PM isused) | 05 , 5 AM |
MM | Minute in two digits | 12 , 02 |
SS | Second in two digits | 07 , 59 |
FFF | Millisecond in three digits | 057 |
AM or PM | AM or PM insertedin text representing time | 3:45:02 PM |
The
formatIn
value must follow these guidelines:- You cannot specify any field more than once. For example,you cannot use
'yy-mmm-dd-m'
because it has twomonth identifiers. The one exception to this is that you can combineone instance ofdd
with one instance of any ofthe other day identifiers. For example,'dddd mmm dd yyyy'
isa valid input. - When you use
AM
orPM
,theHH
field is also required. datevec
does not accept formats that include'QQ'
PivotYear
— Start year of 100-year date range
present minus 50 years (default) | integer
Start year of the 100-year date range in which a two-characteryear resides, specified as an integer. Use a pivot year to interpretdates that specify the year as two characters.
If
formatIn
contains the time of day, thepivot year is computed from the current time of the current day, month,and year. Otherwise it is computed from midnight of the current day,month, and year.Example:
2000
Note
If the input date format specifies a four-character year, thenthe last two characters are truncated, and the first twocharacters specify the year. For example, if the date and pivot yearare specified as
('25122015','ddmmyyyy',2000)
,then the resulting date is 25-12-2020
, not 25-12-2015
.Data Types:
double