| Contents | Index |
| On this page… |
|---|
An example of an enumeration is System.DayOfWeek. To see how to call a .NET method with this input type, use the GetAbbreviatedDayName method in the System.Globalization.DateTimeFormatInfo class. The following code displays the abbreviation for "Thursday".
% Create a DayOfWeek object thisDay = System.DayOfWeek.Thursday; formatObj = System.Globalization.DateTimeFormatInfo; % Display the abbreviated name of the specified day based on the % culture associated with the current DateTimeFormatInfo object. formatObj.GetAbbreviatedDayName(thisDay)
To view the function signature for the GetAbbreviatedDayName method, type:
methodsview('System.Globalization.DateTimeFormatInfo')
Search the list for GetAbbreviatedDayName.
| Return Type | Name | Arguments |
|---|---|---|
| System.String RetVal | GetAbbreviatedDayName | ( System.Globalization.DateTimeFormatInfo this, System.DayOfWeek dayofweek) |
For more information, see:
Search the MSDN Web site at http://msdn.microsoft.com/en-us/default.aspx for the term DateTimeFormatInfo.
In MATLAB, an enumeration is a class having a finite set of named instances. You can work with .NET enumerations using features of the MATLAB enumeration class and some features unique to the .NET Framework. Some ways to use the System.DayOfWeek enumeration in MATLAB:
Display an enumeration member. For example:
myDay = System.DateTime.Today; disp(myDay.DayOfWeek);
Use an enumeration in comparison statements. For example:
myDay = System.DateTime.Today; switch(myDay.DayOfWeek) case {System.DayOfWeek.Saturday,System.DayOfWeek.Sunday} disp('Weekend') otherwise disp('Work day') end
Perform calculations using Underlying Values. For example, the underlying type of DayOfWeek is System.Int32 which you can use to perform integer arithmetic. To display the date of the first day of the current week, type:
myDay = System.DateTime.Today; dow = myDay.DayOfWeek; startDateOfWeek = AddDays(myDay,-double(dow)); ToShortDateString(startDateOfWeek)
Perform bit-wise operations. For examples, see Creating Enumeration Bit Flags.
For more information, see:
![]() | Pass System.String Arguments | Pass System.Nullable Arguments | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |