which functions/argument pairs support argument passing via equality statments?

I had to look up the syntax of empirical mode decomposion emd (https://www.mathworks.com/help/signal/ref/emd.html) today while checking some work in our lab. I noticed that the official doc uses the R/python format for optional arguments as assignments
[imf,residual,info] = emd(X,Interpolation="pchip");
rather than the dictionary-pair type format i've come to expect in matlab over the past decades
[imf,residual,info] = emd(X,'Interpolation','pchip');
While obviously not standard, I'm interesed to know what functions arguments support the assignment format? (I would love it if the answer were 'everything in the future')

댓글 수: 3

"While obviously not standard"
It is standard, since 2021a:
"I'm interesed to know what functions arguments support the assignment format?"
This syntax has nothing to do with any particular function, it depends entirely on the MATLAB syntax being interpreted by the MATLAB engine. Thus on MATLAB versions that support that syntax it works for all functions (even your own):
Why should it only work for some functions? Why would the MATLAB engine go to the effort of identifying some functions and provide this syntax interpretation only for some particular functions?
"It is standard, since 2021a:"
I think it's 'universally implemented' for sure, but i'm not convinced its the 'standard'. If it were 'standard', that, to me, would imply that MOST of the documentation and examples therein for R2023a are not in 'the standard' format
@jessupj: I see no reason why there cannot be multiple "standard" syntaxes. For example, ISO 8601 defines multiple date formats, which by definition are all equally "standard". In this case, that would be "universally implemented".
If your definition of "standard" is something more nebulous, something like "most people use it" or "I see it used in lots of code", then that will take some time (as well as being hard to measure). For example, I know that many users prefer/require writing code that is backwards compatible with previous versions, which completely excludes the usage of this syntax.

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2023년 6월 14일
This Name=Value syntax for passing name-value arguments was introduced in release R2021a as stated in the Release Notes.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2023년 6월 14일

편집:

2023년 6월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by