Variables as arguments in 'listed' function inputs

조회 수: 1 (최근 30일)
Clemens Gersch
Clemens Gersch 2021년 8월 26일
댓글: Steven Lord 2021년 8월 26일
Hi,
would like to replace the path and the .m-filename in the following function with variables instead of writing it directly there.
mcc -mv -N -p D:\Applications\MATLAB\R2012a\toolbox\images Test_Application.m
I can't even properly describe what kind of objects I am dealing with here, so please excuse how my question is formulated. At least the example makes clear what I try to achieve.
Best regards

채택된 답변

Steven Lord
Steven Lord 2021년 8월 26일
What you've written is the command syntax. You want to use the function syntax instead. See this documentation page for more information.
  댓글 수: 2
Clemens Gersch
Clemens Gersch 2021년 8월 26일
편집: Clemens Gersch 2021년 8월 26일
Is the function syntax supported for every function? I currently cannot test this for mcc. I know that both syntax work for disp for example, but both syntax are documented for disp. For mcc I could only find the command syntax documentation. That's why I was wondering if I am stuck to this syntax and need to deal with it.
Would
mcc('-mv','-N','-p',pathname,mfilename)
be the alternative to go?
Steven Lord
Steven Lord 2021년 8월 26일
I believe both forms are only documented for functions that are somewhat likely to be used in both forms. For example, which is often used in command form when its purpose is to show the user where a function is called but can be used in function form when you want to use that information as part of a program's operation. save is another function that documents both forms because it's often used in both.
There are a few commands that people commonly call functions but are actually keywords, and those keywords don't support both forms (global and persistent come to mind) so global A would work but global('A') would not. But other than that you should be able to use either form. In particular, mcc does support both forms.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Package MATLAB Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by