Simulink-based one-dimensional interpolation table parameter loading method

Convert the Excel parameter table to a TXT file through the m script and use the Simulink module to automatically load the data, which solves the problems of tedious manual loading of one-dimensional interpolation tables and high maintenance costs in the Simulink model, realizes automated data loading and calculation, and reduces the modeling cost Cycle and maintenance costs.

CN118734381APending Publication Date: 2024-10-01AVIC AIRBORNE SYST GENERIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410767426.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In Simulink model modeling, when using the Excel parameter table, manually loading the parameters of the one-dimensional interpolation table is cumbersome and has high maintenance costs. Especially when the amount of data is large or parameters change, it is easy to introduce errors and increase maintenance costs.

Method used

Use the m script to convert the Excel parameter table into a TXT data file and a MATLAB data location array, and use the value module and the one-dimensional interpolation table module to automatically load and calculate the interpolation table data to achieve automated data definition and calculation processes.

Benefits of technology

It reduces the error rate and time cost in the model modeling process, and simplifies the maintenance of the parameter table. You only need to modify the Excel table and re-execute the script to update the model parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734381A_ABST
    Figure CN118734381A_ABST
Patent Text Reader

Abstract

The invention discloses a one-dimensional interpolation table data loading method based on Simulink in the technical field of model modeling, and the method comprises the following steps: S1, converting an Excel parameter table into a TXT data file and a Maltb data position array through an m script, the TXT data file being used for recording data, and the Maltb data position array being used for marking positions; s2, a value obtaining module obtains corresponding data values from the TXT data file according to parameter positions in the Maltb data position array and outputs the data values in an array mode; and S3, the one-dimensional interpolation table module completes interpolation calculation and result output according to the obtained data value. According to the one-dimensional interpolation table data loading method, data in an Excel parameter table is automatically converted into a TXT file, and definition, loading, calculation and output of interpolation table data are completed through a value taking module and a one-dimensional interpolation table module, so that the modeling period and maintenance cost in the model modeling process are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of Simulink model modeling, and in particular to a one-dimensional interpolation table parameter loading method based on Simulink. Background Art

[0002] When using Simulink for model building, when it comes to modeling and simulation based on experimental data, the Lookup Tables module in the Simulink model library is often used for model building. Among them, when using the one-dimensional interpolation table module, you first need to input the experimental data in Matlab through the m file to define it as X-axis data and Y-axis data, and the X-axis data and Y-axis data are both standard monotonically increasing 1 times n vectors, and then the corresponding approximate Y-axis data can be interpolated from the input X data.

[0003] However, in the actual complex software modeling process, as the software complexity increases, independent Excel parameter table attachments have been defined in the requirements document to clearly define the parameters required for one-dimensional interpolation. Model modelers need to manually load the parameters required for the numerous one-dimensional interpolation tables in the Excel parameter table into the Matlab workspace one by one through the Matlab one-dimensional vector definition method, while paying attention to the increasing and decreasing form of the experimental data, and then read the data through the Simulink one-dimensional interpolation table module. On the one hand, the data in the Excel parameter table has risen to tens of thousands of rows, and the amount of data is huge. The manual definition method will introduce many model errors; on the other hand, the parameters in the Excel parameter table have changed, and the vector definition in Matlab needs to be modified synchronously, which increases the model maintenance cost. Summary of the invention

[0004] The present application provides a one-dimensional interpolation table parameter loading method based on Simulink, thereby solving the problems of cumbersome process and high model maintenance cost involving Excel parameter tables in Simulink model modeling in the prior art, and achieving the effect of reducing the modeling cycle and maintenance cost of Excel parameter tables in the model modeling process.

[0005] The embodiment of the present application provides a one-dimensional interpolation table data loading method based on Simulink, comprising the following steps:

[0006] S1: Convert the Excel parameter table into a TXT data file and a Maltb data position array through an m script, wherein the TXT data file is used to record data, and the Maltb data position array is used to mark positions;

[0007] S2: The value acquisition module obtains the corresponding data value from the TXT data file according to each parameter position in the Maltb data position array and outputs the data value in the form of an array;

[0008] S3: The one-dimensional interpolation table module completes the interpolation calculation and outputs the result according to the acquired data value.

[0009] The beneficial effect of the above embodiment is that the one-dimensional interpolation table data loading method automatically converts the one-dimensional interpolation table data in the Excel parameter table into a TXT file, and completes the definition of the interpolation table data, the loading of the data, the calculation and output of the data through the value acquisition module and the one-dimensional interpolation table module, thereby reducing the modeling cycle and maintenance cost of the Excel parameter table in the model modeling process.

[0010] Based on the above embodiments, the present application can be further improved as follows:

[0011] In one embodiment of the present application, the m script converting the Excel parameter table in step S1 includes the following steps:

[0012] S1.1: Read parameter data from the Excel parameter table into the Ana_Call.mat file according to the file path and file name of the Excel parameter table compiled in the m script, wherein the first column of the Ana_Call.mat file stores "parameter name + header data name + data name in the table" as the data name; the second column of the Ana_Call.mat file stores the parameter position corresponding to the data name, and the parameter position corresponds to the parameter data and is stored as an array of the data position corresponding to the row number;

[0013] S1.2: traverse all the data in the Ana_Call.mat file, use the first column as the array name of the data position array, the second column as the data number in the data position array, define the data position array of MATLAB into the MATLAB workspace, and obtain the Maltb data position array;

[0014] S1.3: According to the file path and file name input in step S1.1, the data in the Excel parameter table are recorded one by one into the adj.txt file to obtain the TXT data file;

[0015] S1.4: According to the data read in the steps S1.1 and S1.3, repackage the parameter reading function as a function module of S-Function, and load the data from the adj.txt file into the data bus ADJDATA of the MATLAB workspace according to the line number.

[0016] In one of the embodiments of the present application, the parameter positions are accumulated one by one according to the reading process of the Excel parameter table.

[0017] In one of the embodiments of the present application, the data type of each data in the TXT data file is double type.

[0018] In one embodiment of the present application, step S2 specifically includes the following steps:

[0019] S2.1: The value acquisition module uses the data name "parameter name + header data name" as the parameter name to call the global variable in the MATLAB workspace to obtain the header data position array X1 recording the parameter position; uses the data name "parameter name + table data name" as the parameter name to call the global variable in the MATLAB workspace to obtain the table data position array Y1 recording the parameter position;

[0020] S2.2: The value acquisition module obtains the header data value array X2 and the table data value array Y2 from the TXT data file according to the header data position array X1 and the table data position array Y1, and returns the data value array as output.

[0021] In one embodiment of the present application, step S3 specifically includes the following steps:

[0022] S3.1: The one-dimensional interpolation table module obtains the table header data array and the table data array, and adjusts them to ascending order;

[0023] S3.2: Using the table header data value array X2 outputted from step S2, the table data value array Y2 and the input table header data as three inputs, the one-dimensional interpolation table calculation module in the one-dimensional interpolation table module is called to obtain the interpolation output.

[0024] In one of the embodiments of the present application, the one-dimensional interpolation table module is implemented by an S-Function encapsulated in C language; the one-dimensional interpolation table has three inputs, including input header data, header data array, and data array in the table; the one-dimensional interpolation table uses a binary search method to implement a one-dimensional linear interpolation algorithm.

[0025] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0026] 1. This one-dimensional interpolation table data loading method converts the Excel parameter table into parameters in the MATLAB workspace in an automated way, and completes data calculation and output through the value module and the one-dimensional interpolation table module, which can reduce the errors introduced in the manual parameter modeling process and reduce time costs. If the parameter table is modified, you only need to modify the Excel table and re-execute the m script to complete the update of the corresponding parameters of the model, and the cost of model maintenance and modification is also greatly reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for the specific embodiments or the description of the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual scale.

[0028] Figure 1 The present invention is a flowchart of a one-dimensional interpolation table data loading method based on Simulink. DETAILED DESCRIPTION

[0029] The present invention is further explained below in conjunction with specific implementation methods. It should be understood that these implementation methods are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.

[0030] The embodiment of the present application solves the problems of cumbersome process and high model maintenance cost involving Excel parameter tables in Simulink model modeling in the prior art by providing a one-dimensional interpolation table parameter loading method based on Simulink, thereby achieving the effect of reducing the modeling cycle and maintenance cost of Excel parameter tables in the model modeling process.

[0031] The technical solution in the embodiment of the present application is to solve the above problems, and the overall idea is as follows:

[0032] Example:

[0033] like Figure 1 As shown, a one-dimensional interpolation table data loading method based on Simulink includes the following steps:

[0034] S1: Convert the Excel parameter table into a TXT data file and a Maltb data position array through the m script. The TXT data file is used to record data, and the Maltb data position array is used to mark the position.

[0035] An m script refers to a file composed of a series of MATLAB statement commands and functions that implement a certain function. It is called an imperative file. Such files have the file extension ".m".

[0036] Among them, the m script conversion Excel parameter table specifically includes the following steps:

[0037] S1.1: Read parameter data from the Excel parameter table into the Ana_Call.mat file according to the file path and file name of the Excel parameter table compiled in the m script. The first column of the Ana_Call.mat file stores "parameter name + header data name + data name in the table" as the data name; the second column of the Ana_Call.mat file stores the parameter position corresponding to the data name of "parameter name + header data name + data name in the table", that is, the row number. The parameter position is accumulated one by one according to the reading process of the Excel parameter table. The parameter position corresponds to the parameter data and is stored as a data position array corresponding to the row number;

[0038] S1.2: traverse all the data in the Ana_Call.mat file in S1.1, use the first column as the array name of the data position array, the second column as the data number in the data position array, define the MATLAB data position array in the MATLAB workspace, and obtain the Maltb data position array;

[0039] S1.3: According to the file path and file name in S1.1, record the data in the Excel parameter table one by one into the adj.txt file to obtain a TXT data file. One data occupies one line, and the data ends with a line break. The data type of each data is double.

[0040] S1.4: According to the data read in S1.1 and S1.3, repackage the parameter reading function into the function module of S-Function, load the data from the adj.txt file into the data bus ADJDATA of the MATLAB workspace according to the line number, and the data type of each data is double type.

[0041] S2: Obtain the corresponding data value from the TXT data file according to each parameter position in the Maltb data position array through the value acquisition module and output the data value in the form of an array;

[0042] Wherein, the data acquisition in step S2 includes the following steps:

[0043] S2.1: The value acquisition module calls the global variable in the MATLAB workspace by using the data name "parameter name + table header data name" as the parameter name to obtain the table header data position array X1 recording the parameter position; calls the global variable in the MATLAB workspace by using the data name "parameter name + table data name" as the parameter name to obtain the table data position array Y1 recording the parameter position;

[0044] S2.2: Obtain the header data value array X2 and the table data value array Y2 from the data bus ADJDATA according to the header data position array X1 and the table data position array Y1 in S2.1, and return the data value array as output.

[0045] The value module obtains X2 and Y2 based on X1 and Y1. The value module value acquisition process example is as follows:

[0046]

[0047] As shown in Table 1 above, the data position starts from 0:

[0048] Data position array: X1: [0 1 2 3], Y1 [4 5 6 7];

[0049] Then the data value array: X2: [2 3 4 5], Y2 [4 6 8 10];

[0050] That is, the value of B is obtained according to the value of A.

[0051] S3: The interpolation calculation and result output are completed according to the acquired data value array through the one-dimensional interpolation table module.

[0052] Among them, the one-dimensional interpolation table module is implemented by S-Function encapsulated by C language; the one-dimensional interpolation table in the one-dimensional interpolation table module has three inputs, including input header data, header data array, and data array in the table.

[0053] Step S3 is specifically as follows:

[0054] S3.1: The one-dimensional interpolation table module obtains the header data value array X2 and the table data value array Y2 according to the data name, and adjusts them to ascending order;

[0055] That is, first determine whether it is in ascending order. If it is not in ascending order, then reverse the data in the table header and the array in the table; if it is in ascending order, do not process it.

[0056] S3.2: With the table header data value array X2, the table data value array Y2 and the input table header data as three inputs, call the one-dimensional interpolation table calculation module to obtain the interpolation output.

[0057] Among them, the one-dimensional interpolation table module uses the bisection method to implement the one-dimensional linear interpolation algorithm.

[0058] The technical solutions in the above embodiments of the present application have at least the following technical effects or advantages:

[0059] The one-dimensional interpolation table data loading method converts the Excel parameter table into parameters in the MATLAB workspace in an automated manner, and completes data calculation and output through a value acquisition module and a one-dimensional interpolation table module, which can reduce errors introduced in the manual parameter modeling process and reduce time costs.

[0060] In actual applications, control software involves closed-loop control in various scenarios composed of various types of sensors and actuators. Each sensor and actuator corresponds to multiple sets of control parameters in different control scenarios. In this case, the accuracy and efficiency of parameter maintenance through tables are very high. In the model building process, if the parameter values ​​are directly built in the model, once the parameters are modified, it is necessary to find the corresponding model and modify them one by one. With this method, you only need to modify the Excel table and re-execute the m script to complete the update of the corresponding parameters of the model, and the cost of model maintenance and modification is greatly reduced.

[0061] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A one-dimensional interpolation table data loading method based on Simulink, characterized in that: The following steps are involved: S1: Convert the Excel parameter table into a TXT data file and a Maltb data position array through an m script, wherein the TXT data file is used to record data, and the Maltb data position array is used to mark positions; S2: The value acquisition module obtains the corresponding data value from the TXT data file according to each parameter position in the Maltb data position array and outputs the data value in the form of an array; S3: The one-dimensional interpolation table module completes the interpolation calculation and outputs the result according to the acquired data value.

2. The one-dimensional interpolation table data loading method according to claim 1, characterized in that: The m script in step S1 converts the Excel parameter table into the following steps: S1.1: Read parameter data from the Excel parameter table into the Ana_Call.mat file according to the file path and file name of the Excel parameter table. The first column of the Ana_Call.mat file stores "parameter name + header data name + data name in the table" as the data name; the Ana_Call.mat The second column of the file stores the parameter position corresponding to the data name, and the parameter position corresponds to the parameter data and is stored as an array of the data position corresponding to the row number; S1.2: traverse all the data in the Ana_Call.mat file, use the first column as the array name of the data position array, the second column as the data number in the data position array, define the data position array of MATLAB into the MATLAB workspace, and obtain the Maltb data position array; S1.3: According to the file path and file name input in step S1.1, the data in the Excel parameter table are recorded one by one into the adj.txt file to obtain the TXT data file; S1.4: According to the data read in the steps S1.1 and S1.3, repackage the parameter reading function as a function module of S-Function, and load the data from the adj.txt file into the data bus ADJDATA of the MATLAB workspace according to the line number.

3. The one-dimensional interpolation table data loading method according to claim 2, characterized in that: The parameter positions are accumulated one by one according to the reading process of the Excel parameter table.

4. The one-dimensional interpolation table data loading method according to claim 2, characterized in that: The data type of each data in the TXT data file is double type.

5. The one-dimensional interpolation table data loading method according to claim 2, characterized in that: The step S2 specifically includes the following steps: S2.1: The value acquisition module uses the data name "parameter name + header data name / data name in the table" as the parameter name to call the global variable in the MATLAB workspace to obtain the header data position array X1 that records the parameter position; uses the data name "parameter name + data name in the table" as the parameter name to call the global variable in the MATLAB workspace to obtain the data position array Y1 in the table that records the parameter position; S2.2: The value acquisition module obtains the header data value array X2 and the table data value array Y2 from the TXT data file according to the header data position array X1 and the table data position array Y1, and returns the data value array as output.

6. The one-dimensional interpolation table data loading method according to claim 5, characterized in that: The step S3 specifically comprises the following steps: S3.1: The one-dimensional interpolation table module obtains the table header data array and the table data array, and adjusts them to ascending order; S3.2: Using the table header data value array X2 outputted from step S2, the table data value array Y2 and the input table header data as three inputs, the one-dimensional interpolation table calculation module in the one-dimensional interpolation table module is called to obtain the interpolation output.

7. The one-dimensional interpolation table data loading method according to claim 6, characterized in that: The one-dimensional interpolation table module is implemented by an S-Function encapsulated in C language; the one-dimensional interpolation table has three inputs, including input header data, header data array, and data array in the table; the one-dimensional interpolation table uses a binary method to implement a one-dimensional linear interpolation algorithm.