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.

Rating: 4

7667

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.

Course Schedule

Name | Dates | |
---|---|---|

LabVIEW Training | Aug 10 to Aug 25 | View Details |

LabVIEW Training | Aug 13 to Aug 28 | View Details |

LabVIEW Training | Aug 17 to Sep 01 | View Details |

LabVIEW Training | Aug 20 to Sep 04 | View Details |

Last updated: 08 Aug 2023

About Author

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.

read less

Labview Articles

- Dataflow Programming and Data Types in LabVIEW
- LabVIEW Basics
- LabVIEW Interview Questions
- LabVIEW Programming
- LabVIEW Tutorial
- 3d Graphs In Labview
- Labview – Array Controls, Indicators, Constants
- Array Functions And Auto Indexing In Labview
- LABVIEW – Assembling And Disassembling Clusters
- Block Diagram in LabVIEW
- Block Diagram of Toolbar in LabVIEW
- Build a VI Front Panel, Icon and Connector Modular Programming - LabVIEW
- Building a Stand-Alone Application in Modular Programming - LabVIEW
- LAbVIEW – Cluster Controls, Indicators And Constant
- LABVIEW – Conversion Between Arrays And Clusters
- Create LabVIEW Application in Software Environment
- Creating SUBVIS From Sections Of A VI in Modular Programming - LabVIEW
- Customizing Graphs In Labview
- Customizing Graphs And Charts In Labview
- Labview – Delete, Insert And Replace In Arrays
- LABVIEW – Digital Waveform Graphs And Data Type
- Dynamically Formatting Waveform Graphs And Configuring A Graph Or Chart In LABVIEW
- Error Handling And Error Cluster In Labview
- Front Panel Controls and Indicators – LabVIEW
- Graphical System Design Using LabVIEW
- LabVIEW Graphs and Charts
- How to create a time control for loop & Communicating among multiple loops - LabVIEW
- Initializing Arrays In Labview
- Intensity Graphs And Charts In Labview
- Introduction of Repetition And Loops in LabVIEW
- Introduction to Graphical System Design (GSD) Model - LabVIEW
- Introduction to LabVIEW Programming and Its Advantages
- Local and Global Variables in LabVIEW Tutorial
- Miscellaneous Solved Problems in Modular Programming - LabVIEW
- Miscellaneous Solved Problems - LabVIEW
- Miscellaneous Solved Problems in Repetition and Loop - LabVIEW
- Opening Editing Saving and Placing SUBVIS on Block Diagram in Modular Programming
- LABVIEW – Order Of Clusters And Operations
- Overview Of Arrays In Labview
- Overview Of Clusters In Labview
- LabVIEW – Plotting Data And Types Of Waveforms
- Polymorphism In Labview
- Shift Registers in LabVIEW
- Labview Structures
- To Create a Connector Pane in Modular Programming in LabVIEW
- Tools Palette in LabVIEW
- LABVIEW – Two Dimensional Using Loops And Data Structure Using Wires
- VI Properties Dialog Box – LabVIEW
- Virtual Instrumentation for Test, Control and Design - LabVIEW
- Virtual Instrumentation using Labview
- Waveform Charts In Labview
- Waveform Data Type And XY Graphs In LABVIEW
- Waveform Graphs In Labview
- LabVIEW Projects and Use Cases
- How to install LabVIEW on Windows