当前位置: 华文世界 > 教育

平学(46):Matlab入门学习之常见命令

2024-10-12教育

分享兴趣,传播快乐,增长见闻,留下美好。

亲爱的您,

这里是LearningYard学苑!

今天小编为大家带来文章

「平学(46):Matlab入门学习之常见命令」

欢迎您的用心访问!

Share interest, spread happiness, increase

knowledge, leave a beautiful.

Dear you,

this is LearningYard Academy.

Today, the editor brings you an article

"Ping Xue(46):Common commands for beginners to learn Matlab "

Welcome to your visit!

一、思维导图( Mind mapping )

二、学习过程( Learning process )

1. 查询数值属性( Query Numeric Properties )

小编首先给 a,b 随意赋值,然后再调用 whos 来查看两个数值的相关属性,代码运行结果如下图所示:

I first give a,b arbitrary value, and then call whos to see the two values of the relevant properties, the code runs as shown below:

2. 清除命令行窗口(Clear the command line window)

清除命令行窗口需要用到clc这一语句,具体效果如下图所示:

Clearing the command line window requires the statement clc, the effect of which is shown below:

3. 清除变量(Clearing Variables)

首先通过赋值语句对变量a,b进行赋值,可见工作区会保存变量a,b的相关信息,如下图所示:

First of all, the variables a,b are assigned by the assignment statement, and you can see that the workspace will save the information about the variables a,b as shown in the following figure:

其次,再调用clear命令来清除变量,工作区中储存的变量a,b的信息就会被消掉,如下图所示:

Next, the clear command is called to clear the variables, and the information stored in the workspace for variables a,b is eliminated, as shown in the following figure:

4. 清除图形窗口( Clearing the Graphics Window)

小编首先随机画一个二维曲线图,如下图所示:

The editor first draws a random 2D graph as shown below:

然后,调用clf命令来查看该语句的效果,如下图所示:

Then, call the clf command to see the effect of the statement, as shown below:

刚刚图形窗口中的曲线已经被消除掉了。

The curve in the graph window has just been eliminated.

5. 显示或改变当前工作目录(Display or change the current working directory)

小编通过调用cd得到了当前的工作目录,如下图所示:

I got the current working directory by calling cd, as shown below:

6. 显示当前目录或制定目录下的文件(Displays files in the current directory or in a specified directory)

小编通过调用dir得到了当前目录下的文件,如下图所示:

I got the files in the current directory by calling dir, as shown below:

7. 条件语句(Conditional statement)

假设现在需要比较7^8和5^9的大小,可以通过以下代码来实现:

Suppose now you need to compare the sizes of 7^8 and 5^9, which can be done with the following code:

8. 循环语句(Cyclic statement)

现设置一个加法循环,随着a值的增加,b在不断的循环中其值也在增加,如下图所示:

Now set up an additive loop so that as the value of a increases, so does the value of b in a continuous loop, as shown below:

今天的分享就到这里了。

如果您对文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

That's all for today's sharing.

If you have a unique idea about the article

please leave us a message

Let us meet tomorrow.

I wish you a happy day today!

参考资料:Google翻译,百度,通义千问

本文由LearningYard学苑整理发出,如有侵权请在后台留言!

文字 | Ping

排版 | Ping

审核 | yyz