Simcenter Testing Solutions Simcenter Testlab Neo and MATLAB

2024-05-12T18:28:03.000-0400
Simcenter Testlab

Summary


Details


Direct YouTube link: https://youtu.be/Vjr50k7l4L0


In Simcenter Testlab Neo can interface with MATLAB in a few different ways:
  • Import MATLAB data: Data from MATLAB can be read into SImcenter Testlab Neo.
  • Export MATLAB data: Data can be exported to a *.mat MATLAB file format.
  • MATLAB processing: MATLAB scripts and/or process routines can be incorporated in the Process Designer of SImcenter Testlab Neo.  
This article is a step by step tutorial on how to use MATLAB with Simcenter Testlab Neo.

Index of contents
1. External MATLAB Processing
   1.1 Method Setup
   1.2 Creating a Process
   1.3 MATLAB Example     
   1.4 Saving Methods
2. MATLAB File Export
3. MATLAB File Import



1. External MATLAB Processing

External processing can be done in separate programs such as MATLAB to process data in ways that are unique to the user. This allows processing possibilities beyond what the standard methods available in Simcenter Testlab Neo.

The external MATLAB method can be integrated with standard Simcenter Testlab Neo Process Designer methods as shown in Figure 1:

User-added image
Figure 1: Simcenter Testlab Neo process with external MATLAB routine combined with standard methods.

To run external processing using MATLAB, a physical copy of the program and a valid MATLAB license must be present on the computer or network that is being used.

1.1 Method Setup

To use the MATLAB method in Simcenter Testlab Neo Process Designer, first open a blank project or a project that has data that needs processing. At the top, go to File -> Add-ins and select “Interactive Analysis” and “Process Designer”, as shown in Figure 2 below.
 
User-added image
Figure 2: To use the MATLAB method, the "Interactive Analysis" and "Process Designer" methods must be loaded.
 
The add-ins:
  • The Interactive Analysis add-in includes all the supported external processing methods, including Python, and ONNX. The Interactive analysis toolbox also contains core post processing functions such as data editing, filtering, and scaling. 
  • If Process Designer is not turned on, the “Processing” tab will not appear, and no post-processing can be done. 
Then add the data that needs to be post-processed to the “Input Basket”. This can be accomplished a couple of different ways, but one way is to use one of the pivot tables, hover over the data desired, and right click “Add to input basket” as shown in Figure 3.
 
User-added image
Figure 3:Adding data to be analyzed to the Input Basket of SImcenter Testlab Neo.

In this example, the type of pivot table selected is “DOFID vs Function” which will display a matrix table of the channel names vs. the data type. Here, is it time data that will be processed. 

More information:
Once the data has been added to the input basket, select the “Processing” tab that will now appear at the bottom. This where methods can be built and saved for current or future post-processing.

1.2 Creating a Process

In the method library tab on the far left of the screen, browse to the MATLAB method located in the Interactive Analysis section. It is also possible to type “MATLAB” into the search bar to locate the method. Click and drag the MATLAB icon into the Process window over the Input method (Figure 4).
 
User-added image
Figure 4: Creating a new process by clicking and dragging methods.

If the method is dragged on top of the “Input” method, an arrow will automatically connect them. Otherwise, manually draw an arrow by clicking on one of the tiny purple squares on the input method, and then clicking on the MATLAB method. 

After adding the method and correctly connecting it, a few things need to be done before it can be run. The first is to define the “Command Path”. The Command path is where NEO will know where to access the MATLAB executable. Click on the “…” box next to Command path name to locate the executable path location, shown below in Figure 5.
 
User-added image
Figure 5: Click on the "..." icon next to command path to point to the MATLAB executable.
 
This path needs to be set up correctly, or Simcenter Testlab Neo will throw an error and processing cannot be done. 

Next is the part where the coding will be implemented. Select the “…” icon next to “MATLAB code”. Here is where all the coding that a user needs will be placed into the script. This script contains a lot of premade functions to communicate with Simcenter Testlab Neo in the background, but the user editable portion begins after the row of percent signs (%). To get there, scroll to down to about halfway through the popup MATLAB code window (see Figure 6). 
 
User-added image
Figure 6: Editing the MATLAB code for processing under the user edit section. 

The code will accept a variable named “data”. If a user wishes to pass data back and forth between NEO and MATLAB, the variable “data” is what needs to be defined. It is important that the final variable name is called data. A user should not alter code outside of the user input area as it will affect communications with NEO and can cause delays and timeouts. 
 
1.3 MATLAB Example   

This example will apply both "if" statements and "for loops" to demonstrate how both can be used with Simcenter Testlab Neo.  This code was pulled into MATLAB to for explanation purposes only. It is not necessary to code in MATLAB for the code to work with Simcenter Testlab Neo. 

This practice example (shown in Figure 7) will search for the maximum value in a time history, and plot the highest value, until the code encounters a higher value. 
 
User-added image
Figure 7: An example of a MATLAB code that can be implemented in Simcenter Testlab Neo with for-loops and if statements. 

After the script is placed in the correct spot of the MATLAB Code section, it can now be ran. On the bottom bar, select the “Run” button to begin processing, as seen in Figure 8
 
User-added image
Figure 8: Press the "Run" button in the lower left to execute the process.

After the data runs, it will appear in a section called “Active Analysis”. Active Analysis is where data goes to view before it gets saved. If the data is rejected, it will not save to the original project section. If a user chooses to save it, it will get saved as a new folder under the active section. See Figure 9.
 
User-added image
Figure 9: Viewing data under Active Section.  Pressing either Accept or Reject will let use continue.

To view the data that was just processed, select “Active Analysis” and select one of the pivot tables to view. Here, “DOFID vs Run” is selected to sort the channel names from the run names. In the example, the blue curve is the MATLAB generated data, which shows the maximum data value seen at a given point in time. The original red curve is the data used to find the maximum. After processing is done, select either “Accept” or “Reject” at the bottom to continue with viewing and processing data. 

1.4 Saving Methods

To reuse the same code in a MATLAB method, save the method using the “Save” method icon located under the “Process” tab at the top (shown in Figure 10).
 
User-added image
Figure 10: Use the Process tab and "Save As..." to store the process for future use.

Name the process method and click ok. To load, repeat these steps with the “Open” icon to load in a process. Simcenter Testlab Neo will remember the user inputted code and save it for future use. 

There is also a "Python" method with example code and a generic "External Processing" method available as well.

2. Matlab File Export

It is possible to export Simcenter Testlab data from Neo into MATLAB file format directly.  Simply right click on the data and choose "Export..." as shown in Figure 11.
 
User-added image
Figure 11: To export data from Simcenter Testlab Neo project to MATLAB file format, right click and choose "Export..." and then select MATLAB.

Choose "MATLAB" from the "Export to" pulldown menu in the upper left. Press OK.

For time data, there is an "Export" method that can be used as part of a Simcenter Testlab Neo process to incorporate the export automatically as shown in Figure 12.
 
User-added image
Figure 12: SImcenter Testlab Neo process ending with MATLAB file export.

In the export method, users can select the destination directory and the naming scheme for the exported MATLAB files.  By incorporating the "Export" method in the process, conversion to MATLAB does not need to be performed as a separate step.

The result of the export operations are a *.mat file.  The data is stored in a structured array with some specific header information (units, names, etc).  See the next section for more information on the header information.

3. MATLAB File Import

To read MATLAB data files into Simcenter Testlab, the data must be stored in a structured array with some specific header information.  The header information allows Simcenter Testlab to recognize the engineering units, the X-axis spacing, names, etc.  There is a CreateHeader MATLAB script that can be used to convert MATLAB data to a format that Simcenter Testlab will read (Figure 13).  
 
User-added image
Figure 13: The CreateHeader MATLAB script that is delivered with Simcenter Testlab for modifying MATLAB data to a recognizable format.

The script is delivered with the software and located in C:\Program Files (x86)\Simcenter\Testlab {revision}\Tecware\contrib\MATLABviaEDA> for 32 bit installations. For the 64 bit versions, it is at C:\Program Files\Simcenter\Testlab {revision}\Tecware\contrib\MATLABviaEDA.



Hope this guide is helpful for introducing custom MATLAB routines to work with Neo. 

Questions?  Email steff.nelson@siemens.com.

Related Links:

KB Article ID# KB000132423_EN_US

Contents

SummaryDetails

Associated Components

Simcenter Testlab Digital Image Correlation Testlab Environmental Testlab Acoustics Testlab Data Management Testlab Desktop Testlab Durability Testlab General Acquisition Testlab General Processing & Reporting Testlab Rotating Machinery & Engine Testlab Sound Designer Testlab Structural Dynamics Testlab Turbine