Syntax
w=kw([dstr])
Input Parameter
dstr : | | empty (returns the current kw), # (returns the dates) or date (returns the kw of the date) |
Output Parameter
Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, named kw
, is designed to determine the calendar week (KW) based on the input parameters. It is part of the SolidGeometry library and was introduced in version 5.0.
Input Parameters
- dstr: This parameter can be empty, a scalar, or a date string. The behavior of the function changes based on the type of input:
- If empty: The function returns the current calendar week.
- If a scalar: The function returns all dates that fall within the specified week of the current year.
- If a date string: The function returns the calendar week of the specified date.
Output Results
- w: The output can be either the week number or a list of dates, depending on the input.
Algorithm Details
The function begins by retrieving the first input parameter using getfuncparams
. It then checks the type of dstr
:
- If
dstr
is empty:
- The function calculates the current week number using
week(datetime)
.
- If no output is expected (
nargout==0
), it prints the current week number using dbprintf
.
- If
dstr
is a scalar:
- The function retrieves the current year using
datestr(now,'yyyy')
.
- It creates a range of dates from January 1st to December 31st of the current year.
- It filters these dates to find those that match the specified week number using
week(t)==dstr
.
- If
dstr
is a date string:
- The function converts the date string to a datetime object and calculates its week number using
week(datetime(dstr))
.
Algorithm explaination created using ChatGPT on 2025-08-18 22:58. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21