Octave Tutorial (a)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/xiewenrui1996/article/details/101713319

I will teach you a programming language: Octave language. You can use it to very quickly realize this course we have already learned, or machine learning algorithms to learn.

In the past I have been experimenting with different machine learning to teach programming languages, including C ++ , the Java , Python , Numpy and Octave . I found that when using as Octave when such a high-level language, students can better and faster to learn and master these algorithms. In fact, in Silicon Valley, I often see people carry out large-scale machine learning project, which is commonly used programming languages Octave . (Editor's note: This is the situation, now mainly used Python )

Octave is a good original language ( Prototyping Language ), using Octave you can achieve your algorithm quickly, the rest of the things, you just need a massive allocation of resources, you only have to spend time with C ++ or Java these languages to re-implement the algorithm on the line. Development time is very valuable, machine learning time is very precious. So, if you let your learning algorithm in Octave rapid implementation on the future realization of the basic idea, then C ++ or Java to rewrite, so you can save a lot of time.

As far as I can see, most people use for machine learning the original language is Octave , MATLAB , Python , NumPy  and R .

Octave is good because it is open source. Of course MATLAB is also very good, but it is not everyone can afford. (Looks like a domestic student fees MATLAB , MATLAB functions than Octave more powerful, there are a variety of online D version can be downloaded). The work also with machine learning lesson matlab 's. If you can use MATLAB , you can also use this class there.

If you would Python , NumPy or R language, I have seen someone with  R 's, as far as I know, these people had to drop out because these languages are slow in developing, but also because these languages, such as: Python , NumPy syntax compared to Octave , that was a little more trouble. Because of this, I strongly recommend not to use NumPy or R to complete the course work, I recommend this course with Octave to write programs.

This video will quickly introduce a series of commands, the goal is to quickly demonstrate, through a series of Octave commands let you know Octave what can be done.

Start Octave :

Now open Octave , this is the Octave command line.

 

Now let me show basic Octave Code:

Input 5 + 6, and then to give 11.

Input 3 - 2,5 × 8,1 / 2,2 ^ 6 like, to yield the corresponding answer.

 

These are the basic math operations.

You can do logical operations, e.g., 1 == 2, evaluates  to false  ( false ), where the command indicates the percent Notes, 1 == 2 evaluates to false, represented here by zero.

Please note that the wording does not mean that this is the symbol of wavy lines plus equal sign (= ~) instead of the equal sign, equal to an exclamation point (! =), Which is and some other programming languages ​​is not the same place.

Let us look at a logical operator && 0, double & notation logic, a false determination && 0, 1 and 0 or 0 || 1 operation, which evaluates to true.

As well as an exclusive OR operation XOR ( 1, 0 ), which returns a value of 1

Written from left to right  Octave 324.x version is the default Octave prompt, it shows the current Octave version, as well as other relevant information.

If you do not want to see that suggest that there is a hidden command:

input the command

Now it has become simplified command prompt.

Next, we will talk about Octave variables.

Now write a variable, the variable assignment $ A $ 3, and press the Enter key to display the variable equal to $ A $ 3.

如果你想分配一个变量,但不希望在屏幕上显示结果,你可以在命令后加一个分号,可以抑制打印输出,敲入回车后,不打印任何东西。

其中这句命令不打印任何东西。

现在举一个字符串的例子:变量$b$等于"hi"。

$c$等于3大于等于1,所以,现在$c$变量的值是真。

如果你想打印出变量,或显示一个变量,你可以像下面这么做:

设置$a$等于圆周率$π$,如果我要打印该值,那么只需键入a像这样 就打印出来了。

对于更复杂的屏幕输出,也可以用DISP命令显示:

 

这是一种,旧风格的C语言语法,对于之前就学过C语言的同学来说,你可以使用这种基本的语法来将结果打印到屏幕。

例如 ^{T}命令的六个小数:0.6%f ,a,这应该打印$π$的6位小数形式。

也有一些控制输出长短格式的快捷命令:

 

Guess you like

Origin blog.csdn.net/xiewenrui1996/article/details/101713319
Recommended