File Exchange

image thumbnail

when - when a function was introduced by MATLAB

version 1.5.0.0 (1.82 KB) by Reza Ahmadzadeh
This function shows the version in which the input function was introduced.

11 Downloads

Updated 24 Jul 2019

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

The input to this function is a matlab/simulink function name, such as 'rand' as a string. The function checks the version in which the input function was introduced. This function also accepts a group as input functions to check. See the following examples:
Example 1:
>> when('rand')
## rand is a built-in function (Introduced before R2006a)
Example 2:
func_name = {'rand','plot','grid','findstr','weboptions'};
when(func_name)
## rand is a built-in function (Introduced before R2006a)
## plot is a built-in function (Introduced before R2006a)
## grid is a Matlab function or an ordinary m-file (Introduced before R2006a)
## findstr is a built-in function (Introduced before R2006a)
## weboptions is a Matlab function or an ordinary m-file (Introduced in R2014b)

Cite As

Reza Ahmadzadeh (2019). when - when a function was introduced by MATLAB (https://www.mathworks.com/matlabcentral/fileexchange/54483-when-when-a-function-was-introduced-by-matlab), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

John D'Errico

Thank you. Something that belongs as part of MATLAB! If I had any qualms, it is that I wish it worked for toolbox functions too. As a FEX contributor and person who answers questions on Answers, one thing that I frequently need to do is check when a function was released.

A more extreme wish is that it show the complete release history, telling the user what changes were made and in what release. That is surely beyond the scope of this code though.

And then for those of us who will dare to dream, I want a whenwill utility. That would tell me when will something be introduced, in the future. (Only kidding here.)

The prosaic part of me who will give this a rating says 5 stars anyway.

@Frederick Zittrell and @Addy - Thanks for the comments.

Addy

Not sure of it is working or not..
>> when('hilbert')
## [hilbert] is a Matlab function or an ordinary m-file (No information found).
>> when('feedforwardnet')
## [feedforwardnet] is a Matlab function or an ordinary m-file (No information found).
>> when('plot')
## [plot] is a built-in function (No information found).

Very useful!
However, I needed to adapt your code a bit:
- Doc pages are only accessible via https; your code queries http URLs.
- Some doc pages are named with the lower-case version of the function name (e. g. mustBeMember is only accessible via https://mathworks.com/help/matlab/ref/mustbemember.html), so I added another 'isemtpy(str)' check that queries the doc page with 'lower(fname)'.

Seban

breathi

Thank you @ Stephen Cobeldick! I consider fixing the bugs.

A very tidy submission with neatly written code, a short but clear description and help. For most standard inbuilt functions it works well, as per its help:

>> when('ismac')
## [ismac] is a Matlab function or an ordinary m-file (Introduced in R2007a).

However there is are a few minor bugs with some edge-cases:

1. If no inbuilt/MATLAB function is found then an error is thrown. This can be easily fixed by adding an |else| statement at the end of the local function |checkFunctionName|:

else
strr = sprintf('## [%s]%s.',fname,w);
end

This is easy to implement as the author had already generated the required message strings in variable |w|, but for whatever reason did not use them for the non-function cases.

2. If the name of a non-MATLAB (i.e. your own) function is provided then this submission gets a bit confused and returns the wrong error message:

>> when('num2words')
Error! check your connection.
Connection error.

This occurs because it passes the |exist| test, but then cannot find any online documentation. This also occurs for functions without online documentation:

>> when('jet')
Error! check your connection.
Connection error.

This lack of one-to-one correspondence between using |exist| on the local MATLAB installation and yet accessing the most-up-to-date-version online means it is also not possible to check the date of functions not installed on the local machine:

>> when('uniquetol')
## [uniquetol] does not exist.

Perhaps some check if a function |exist|s but is not online could solve this.

Overall this is a handy function, but could do with a bit of testing and thought for some of these edge-cases. It would also be simplified by using |fprintf| inside the local function |checkFunctionName| and not returning a variable to display.

Updates

1.5.0.0

Image updated

1.4.0.0

- upgraded towards working with https
- fixed issues with the combined lower-upper case filenames

1.3.0.0

Another bug fixed!

1.2.0.0

passing no variable to the main function.

1.1.0.0

Add a screenshot.

1.1.0.0

First bug mentioned by Stephen Cobeldick was fixed. Thank you Stephen!

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux