matlab 语法_MATLAB中的语法

matlab 语法

The syntax is the method by which the programmer give various commands to the system or the software. These commands are given to perform the specific task like.

语法是程序员用来向系统或软件发出各种命令的方法。 这些命令是用来执行特定任务的。

In C OR C++, we give a command like #include<stdio.h> ,as it is giving command to the compiler to add the header file name stdio.h to the program or to execute it in the same way there are various syntax present in the MATLAB to give instruction to the software to perform the specific tasks.

在C或C ++中,我们给出类似#include <stdio.h>的命令,因为它向编译器发出命令以将头文件名stdio.h添加到程序中或以相同的方式执行该程序,并且存在各种语法MATLAB中提供的指令,以指示软件执行特定任务。

First, when we open the MATLAB software it seems very complex to use as a calculator but we can easily use the software if we know the set of rules through which we can easily handle it.

首先,当我们打开MATLAB软件时,用作计算器似乎非常复杂,但是如果我们知道可以轻松处理的一组规则,就可以轻松使用该软件。

Notes for working in the command window

在命令窗口中工作的注意事项

  1. To type a command the cursor must be placed next to the command prompt (>>).

    要键入命令,必须将光标放在命令提示符(>>)旁边。

  2. Once a command is typed and the enter key is pressed, the command is executed. However, only the last command is executed. Everything executed previously is unchanged.

    键入命令并按Enter键后,将执行该命令。 但是,仅执行最后一条命令。 先前执行的所有内容均保持不变。

  3. Several commands can be typed in the same line. This is done by typing a command between the commands. When the enter key is pressed the commands are executed in order from left to right.

    可以在同一行中键入多个命令。 通过在命令之间键入命令来完成此操作。 当按下回车键时,命令从左到右依次执行。

  4. It is not possible to go back to a previous line in the command window, make a correction, and then re-executed the command.

    无法返回到命令窗口中的上一行,进行更正,然后重新执行命令。

  5. A previously typed command can be recalled to the command prompt with the up-arrow key. When the command is displayed at the command prompt, it can be modified if needed and executed. The down-arrow key can be used to move down the previously typed commands.

    可以使用向上箭头键将先前键入的命令调回命令提示符。 当命令显示在命令提示符下时,可以根据需要对其进行修改并执行。 向下箭头键可用于向下移动先前键入的命令。

  6. If a command is too long to fit in one line, it can be contained to the next line by typing the periods… (called an ellipsis) and pressing the enter key. The continuation of the command is then typed in the new line. The command can continue line after line up to a total of 4096 characters.

    如果命令太长而不能放在一行中,则可以通过键入句点…(称为省略号)并按Enter键将其包含在下一行中。 然后在新行中键入命令的继续。 该命令可以逐行继续,最多4096个字符。

Way to execute the program in MATLAB

在MATLAB中执行程序的方式

    Type a valid expression, 
    for example:
        6+6
    And press ENTER

When you click execute button or type CTRL+E, MATLAB executes it immediately and the result will return as,

单击执行按钮或键入CTRL + E时 ,MATLAB将立即执行它,结果将返回为,

    Ans =12

In the same way we can execute various commands like,

同样,我们可以执行各种命令,例如

    4^5             power of 5 raised to 4
    Cos (pi/2)      cos of angle 90 degree
    567*678         first number multiplied to the second

Above are some ways to give the command to MATLAB software and then press ENTER or CTRL+E to execute and after pressing the execution button it will show the result.

上面是将命令提供给MATLAB软件 ,然后按EnterCTRL + E的方法 ,然后按执行按钮将显示结果。

MATLAB provides some special expressions for some mathematical symbols, like pi for 22/7, inf for infinity I (or j) for sqrt(-1).

MATLAB提供了一些独特的表达了一些数学符号,如pi22/7,INF为无限I(j)开方(-1)。

There are also various symbols used in MATLAB which act as syntax like given below,

MATLAB中还使用了各种符号,它们的语法如下所示,

  1. (>>) The point from where we can start to write our program.

    ( >> )从此处开始编写程序。

  2. (;) If a semicolon is typed at the end of a command the output of the command is not displayed. It is useful when the result is known.

    ( ; )如果在命令末尾键入分号,则不会显示该命令的输出。 当结果已知时,它很有用。

  3. (%) When this symbol is typed at the beginning of a line, the line is designated as a comment.

    ( )在行的开头键入此符号时,该行被指定为注释。

Example to execute a program

执行程序的例子

    >> 7 + 8/2          % type and press enter %
    Ans: 11             % 8/2 is executed first %


翻译自: https://www.includehelp.com/matlab/syntax-in-matlab.aspx

matlab 语法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值