By using MathScript, we will do arithmetic operations on the matrices. In this Matrix Operations with Arrays in LabVIEW, you will learn how to work with MathScript and perform matrix operations with arrays.
LabVIEW is defined as a graphical programming environment engineers utilise for developing automated research and production test systems. To handle matrices, LabVIEW provides MathScript. In MathScript, we can write and execute the code.
MathScript will allow us to declare matrices in the form of arrays.
After declaring the matrices, we will do arithmetic operations on those matrices. In this Matrix Operations with Arrays in LabVIEW, you will learn to use arrays for doing matrix operations.
Matrix Operations with Arrays in Labview: Table of Contents |
We can add the textual math to the LabVIEW development environment with the compiler for “.m” files added by the LabVIEW MathScript Modules. Graphical and Textual approaches can be mixed together in MathScript. It can be used for control designs, algorithm development, also comprising data analysis, processing, and signal processing activities. We can deploy our “.m” code to real-world hardware without extra code creation steps.
It has several advantages over different programming languages; we can save valuable time with LabVIEW MathScript, which is compatible with all the .m file compilers like OCTAVE, MATLAB, etc. In the MathScript window, we can write and execute the code as sample LabVIEW code. If we have to change the matrices, we can use the MathScript window.
If you would like to Enrich your career with an Android certified professional, then visit Mindmajix - A Global online training platform: “LabVIEW training” Course.This course will help you to achieve excellence in this domain. |
Open the LabVIEW window and click on the tools button in top bar, a dropdown will emerge, choose the MathScript window in that menu as displayed in the following figure:
When we click the mathscript window, a window will emerge with initialising written over it, as displayed in the following figure:
After initiating the window, mathscript will give you the help instruction. This help instruction is very critical in mathscript. See the following figure:
When we type “help classes” in the following window, as displayed in the following figure:
A window will emerge that will show all the help features that can be required while writing the code in the mathscript. See the following figure for reference.
When we open the mathscript window, it will display the variable window at the right side of the window as displayed in the below figure:
All the variables, once declared or used in the script or command window, will be displayed in this section, irrespective of the variable used, global or local. The code developed in mathscript cannot be accessed again since it is not saved anywhere. But, we can write the code in the mathscript that can be saved.
Related Article: LabVIEW Tutorial |
The script for writing multiple lines of code and saving it for the future is also available in the mathscript window. The following figure displays a blank script in which we can write the required code.
After opening the LabVIEW window, press the Tools button; on top bar, a dropdown menu will emerge, and from that menu, press on Mathscript window as displayed in the following figure:
In window emerges by opening mathscript window, and press the script button available beside the variables section as displayed in the below figure:
This will create the script in the mathscript and you can save it by pressing <Ctrl+S> or by clicking save button made on top of script as displayed in the following figure:
Matrices work like arrays. We can specify or initialize the matrix by dividing two columns by the semicolon(;) as displayed in the following figure:
We can execute this by pressing the <Ctrl+R> by pressing the green arrow button on top of the script as displayed in the following figure:
The output of this code line will be shown in output window as soon as we click the green arrows as displayed in the following figure:
This indicates that separating two arrays by the semicolon(;) will create the matrix with the array as the first row of the matrix and the array after the semicolon as second row of matrix since it can be seen from output window.If we don’t want every line of our code to be shown in the output window, put a semicolon at the line end, this semicolon will subdue the output of the command to be shown in output window.
Grace your interview by having these: LabVIEW Interview Questions |
By default, all the mathscript command line contains a printing option with it and the semicolon will help LabVIEW to repress the printing option of the command as displayed in the following figure:
For doing the mathematical operations on the matrix we have to specify another matrix i.e. a matrix ‘c’. Now if we have to add the matrix a “+” sign will do, this the main advantage of using the mathscript in LabVIEW. Placing the “+” sign between two matrices will insert the matrices as per the matrix addition rules as displayed in the following figure:
We can do Matrix subtraction in an easy way by using the “-” sign rather than the “+” sign. Putting a”-” sign between two matrices will subtract one matrix from another matrix as per the matrix subtraction rules, as displayed in the following figure:
Coming to Matrix Multiplication we all know that matrix multiplication is not as simple as matrix addition and subtraction. For evaluating the matrix multiplication, we have to use the rules of the matrix multiplication.
One of the main advantages of utilising the mathscript is that we can assess the matrix multiplication by simply putting an asterisk(*) symbol between two matrices. Putting a ‘*’ symbol between two matrices will multiply one matrix with other matrices as per the matrix multiplication rules, as displayed in the following figure.
However, what if we don’t want to implement matrix multiplication and we want to multiply the corresponding elements of two matrices? Mathscript also enables us to so through the dot(.) in conjunction with the asterisk(*) symbol. Putting ’*’ symbols between two matrices will multiply the corresponding elements of one matrix with other matrices, as displayed in the below figure:
In LabVIEW, we will do matrix operations using MathScript and Arrays. MathScript will make matrices work as arrays, and by declaring the arrays, we can create matrices, and by using addition, subtraction, and multiplication symbols, we can do the matrix operations. I hope this Matrix Operations with Arrays in LabVIEW blog will give you enough information about performing matrix operations in LabVIEW. If you have any queries, let us know by commenting below.
Name | Dates | |
---|---|---|
LabVIEW Training | Nov 02 to Nov 17 | View Details |
LabVIEW Training | Nov 05 to Nov 20 | View Details |
LabVIEW Training | Nov 09 to Nov 24 | View Details |
LabVIEW Training | Nov 12 to Nov 27 | View Details |
I am Ruchitha, working as a content writer for MindMajix technologies. My writings focus on the latest technical software, tutorials, and innovations. I am also into research about AI and Neuromarketing. I am a media post-graduate from BCU – Birmingham, UK. Before, my writings focused on business articles on digital marketing and social media. You can connect with me on LinkedIn.