Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the basic syntax of Octave

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "what is the basic grammar of Octave", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "what is the basic grammar of Octave" can help you solve your doubts.

Octave basic function generating matrix function

Eye (n): generate a unit matrix with n rows and n columns

Rand (nQuine m): randomly generate n rows and m columns of random numbers whose size ranges from 0 to 1.

Randn (m): generate random numbers with n rows and m columns according to Gaussian distribution

Ones (m): generate a matrix with n rows and m columns with elements of 1

Zeros (m): generate a matrix with n rows and m columns with zero elements.

Matrix operation function

B = A (nvir m): assign the values of rows n to m of matrix A to matrix B

A (nMagnem): take n rows and m columns of elements

A ([1 3],:): displays all the elements of the first and third rows of matrix A.

A (2): show all the elements in the second row of matrix A.

A = [A _ quotient B]: extend the base B to the right of matrix An and reassign the resulting new matrix to A.

A = [Aten B]: extend the basic B to the lower edge of the matrix An and reassign the resulting new matrix to A.

A (:): all the elements in An are sequentially formed into a new column vector in the direction of the column.

Reshape (A (i j), n, m): an is a column vector. I and j denote that the terms I to j of the column vector are taken out and reorganized into another matrix, and n and m are the corresponding rows and columns respectively.

Matrix operation

Multiplication of matrices

A. multiplib: multiply each element

A ^ 2: square the element

1.Compact a: reciprocal the elements of a.

Log (a): logarithm

Exp (a): take e as the base and an as the power

Abs (a): find the absolute value

V+ones (length (v), 1): add 1 to the elements of v

Transposition of Avalanche A

Prin (A): inverse or pseudo inverse

Sum (a): data summation in a matrix

Prod (a): product

Floor (a): round up

Ceil (a): round down

Max (A, [], 1): take the maximum value of each column

Max (A, [], 2): take the maximum value of each row

Max (max (A)): the maximum value in a matrix

Simple drawing

Plot (XMagol y): draw with x as Abscissa and y ordinate. The third parameter is optional, indicating the image type (the color of'r' is red).

Hold on: draw multiple pictures in the same image. Usage: first draw plot (tPowery1), then enter and exit hold on;, and then enter plot (trecovery2), that is, two images can be displayed simultaneously.

Xlabel (xString): xString represents the name of the x-axis

Ylabel (yString): yString represents the name of the y-axis

Legend (string1, string2 …) Name each curve according to the drawing order

Title (tString): tString represents the chart name

Print-dpng 'file.png': saves the chart as a png picture

Close: turn off the currently open chart

Figure (n): use this function before using the plot function to ensure that n is different and multiple chart windows can be opened without being overwritten.

Subplot (1): divide the drawing into 1 / 2 grids and use the first grid when drawing

Axis ([x1recovery2]): sets the scale value. [x1recovery2] is the scale range of the horizontal axis, and [y1recoery y2] is the scale range of the vertical axis.

Imagesc (A): draw a color graph matrix for matrix A, with different values corresponding to different color depths.

Common operation

PS1 ("> >"): change the command line leading symbol to "> >"

Size (A, [N]): an is a matrix. When the first parameter is omitted, the function returns an array [n < m], where n is the number of rows of An and m is the number of columns of A. the second parameter is optional, which represents the dimension of the matrix and returns the size of the Nth dimension. For example

A = 1 2 3 4 5 6 7 8 9size (A) = 9 1size (A Magi 1) = 9size (A Magi 2) = 1

Disp (): print a variable or string

Pwd: show current path

Load: loading data files

Who: query variable names in the work area

Whos: query the details of the work area

Clear: clear a variable (clear x). If there are no variables after clear, clear all variables.

Clc: clear the screen

Save file A: store the A matrix in the file file

After reading this, the article "what is the basic grammar of Octave" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report