calendar
指定した月のカレンダー
説明
calendar
は、現在の月のカレンダーを従来の形式で表示します。1 週間は日曜日から土曜日までで、日曜日が 1 列目です。表示形式には、月、年、および曜日の短縮名を示すヘッダーが含まれます。
c = calendar
は、現在の月のカレンダーを 6 行 7 列の数値行列として返します。行列にはヘッダーはありません。
c = calendar(___)
は、指定された月のカレンダーを 6 行 7 列の数値行列として返します。
例
現在の月のカレンダー
現在の月のカレンダーを表示します。表示形式には、月名、年、および曜日を示すヘッダーが含まれます。
calendar
Jan 2024 S M Tu W Th F S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 0 0 0 0 0
カレンダーを数値行列として返します。行列にはヘッダーはありません。
c = calendar
c = 6×7
0 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 0 0 0
0 0 0 0 0 0 0
月と年の指定
1999 年 12 月のカレンダーを表示します。
calendar(1999,12)
Dec 1999 S M Tu W Th F S 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 0 0 0
datetime
値またはテキストのタイムスタンプの指定
datetime
値を作成します。次に、その datetime
値で指定した月と年のカレンダーを表示します。
d = datetime("now")
d = datetime
25-Jan-2024 20:24:09
calendar(d)
Jan 2024 S M Tu W Th F S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0 0 0 0 0 0
入力引数としてテキストのタイムスタンプも指定できます。"2022-01-01"
で指定した月と年の 2022 年 1 月のカレンダーを表示します。
d = "2022-01-01"
d = "2022-01-01"
calendar(d)
Jan 2022 S M Tu W Th F S 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0
入力引数
y
— 年番号
非負の整数
年番号。非負の整数として指定します。
m
— 月番号
1 ~ 12 の正の整数
月番号。1 ~ 12 の正の整数として指定します。月番号は、次の表に示す月に対応します。
月番号 | 月名 |
---|---|
1 | 1 月 |
2 | 2 月 |
3 | 3 月 |
4 | 4 月 |
5 | 5 月 |
6 | 6 月 |
7 | 7 月 |
8 | 8 月 |
9 | 9 月 |
10 | 10 月 |
11 | 11 月 |
12 | 12 月 |
d
— 月と年
datetime
スカラー | テキストのタイムスタンプ
月と年。datetime
スカラーまたは形式に年、月、日を含むテキストのタイムスタンプとして指定します。時間、分、秒の成分は無視されます。
従来のコードをサポートできるように、calendar
ではシリアル日付値を入力として使用することもできますが、この方法は推奨されません。詳細については、バージョン履歴を参照してください。
データ型: datetime
| string
| char
制限
MATLAB® Online™ は、現在の月を現地時間ではなく協定世界時 (UTC) から決定します。
バージョン履歴
R2006a より前に導入R2022b: シリアル日付値の入力は非推奨
calendar
でシリアル日付値を入力として使用することは推奨されません。時点を表すには、代わりに datetime
データ型を使用します。datetime
データ型を使用すると、柔軟な日付と時刻の形式、ナノ秒単位の精度のストレージ、タイム ゾーンと夏時間を考慮するためのプロパティを使用できます。
シリアル日付値を datetime
値に変換するには、関数 datetime
を使用します。datetime
値を使用してカレンダーを表示します。
d = datetime(738522,"ConvertFrom","datenum")
d = datetime
01-Jan-2022
calendar(d)
Jan 2022 S M Tu W Th F S 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 0 0 0
現在のところ、シリアル日付値のサポートを削除する予定はありません。
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)