MATLAB Fundamentals>Programming Constructs>Course Example - Comparing Prices>(2/2) Reserved Keywords
任务1:
Keywords are reserved words with special meanings.
To see a list of MATLAB programming keywords, type:iskeyword
解答1:
iskeyword
结果1:关键字一共20个,如下
'break'
'case'
'catch'
'classdef'
'continue'
'else'
'elseif'
'end'
'for'
'function'
'global'
'if'
'otherwise'
'parfor'
'persistent'
'return'
'spmd'
'switch'
'try'
'while'
附加练习:
MATLAB programs can make use of keywords to control execution of the code. Keywords are the basic programming components of the MATLAB language. You can use them to build programming constructs that allow your programs to make decisions or repeat a procedure multiple times. Use these constructs to make your code more robust, more flexible, and more maintainable.
MATLAB will not allow you to use a keyword as a variable.
end = pi end = pi ↑ Error: Illegal use of reserved keyword "end". |
笔记:
MATLAB程序可以利用关键字来控制代码的执行。关键字是MATLAB语言的基本编程组件。您可以使用它们来构建编程结构,使您的程序能够多次做出决策或重复一个过程。使用这些构造可以使代码更健壮、更灵活、更易于维护。
MATLAB不允许您将关键字用作变量。