Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup 2D Table Column and Row Parameters exchanged in FMU Interface #37

Open
erlinghs opened this issue Nov 11, 2021 · 2 comments · May be fixed by #39
Open

Lookup 2D Table Column and Row Parameters exchanged in FMU Interface #37

erlinghs opened this issue Nov 11, 2021 · 2 comments · May be fixed by #39

Comments

@erlinghs
Copy link

erlinghs commented Nov 11, 2021

Hello together,

we just noticed that the column and row are exchanged from a Lookup 2D Table in Simulink in the FMU Parameter interface (XML).
This issue is just concerning the parameter "name" in the XML. The parameter "valueReference " is totally fine.

For example, if the table in Simulink Lookup 2D Table looks like this:
A=[
0 1 2
0 1 2
0 1 2
0 1 2]

So 4 rows and 3 columns.
In the XML the tunable Parameter "name" A should be listed with its default parameters like this if I'm correct.

A[1,1]=0
A[1,2]=1
A[1,3]=2

A[2,1]=0
A[2,2]=1
A[2,3]=2

A[3,1]=0
A[3,2]=1
A[3,3]=2

A[4,1]=0
A[4,2]=1
A[4,3]=2

But what happens with the parameter "name" is this in the XML:

A[1,1]=0
A[1,2]=0
A[1,3]=0

A[2,1]=0
A[2,2]=1
A[2,3]=1

A[3,1]=1
A[3,2]=1
A[3,3]=2

A[4,1]=2
A[4,2]=2
A[4,3]=2

For the row entries it reads out the column and if the last index of the row is reached A[1,3]=0 it just writes the next index of the column in the next row A[ 2,1] = 0. Then it has read one full column and writes the next first column entry where it stopped in the row A[2,2]=1

To reproduce this just create a Lookup 2D Table in Simulink and make the table parameter tunable.
Generate the FMU and check the XML with its Parameters.

The simulation results between Simulink model and FMU are the same. Therefore, i guess the generated Code is correct. Just the connection between tunable parameter index and actual table in the code is off.

Is there a way to correct this?

Thanks alot in advance.

Best Regards
Stefan

Expected behaviour and actual Simulink Lookup 2D Table parametrization from a more complex table:
image
Read out from XML or loaded FMU in Simulink Parameter interface:
image

Simulink 2017b, 2018b, 2020b
Simulix Version 1.0.0

@beutlich
Copy link
Contributor

Support for lookup tables was added in 718b392. As I no longer have access to Simulink (Coder), you might want to check the code (changes) yourself.

beutlich added a commit to beutlich/Simulix that referenced this issue Nov 3, 2023
* MATLAB uses column-major array indexing
* refs Kvixen#37
@beutlich beutlich linked a pull request Nov 3, 2023 that will close this issue
@beutlich
Copy link
Contributor

beutlich commented Nov 3, 2023

@erlinghs I gave it a try (untested). See #39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants