Hi there!
I have developed a component in Modelica to import values from a Matlab struct into MapleSim and use it with other components. This data is saved in a ".mat" file and the struct was constructed as follows:
% Matlab command window % Struct name is "bemData" saved in a v7 format to be read in by Modelica>> bemData.m33 = 100;>> bemData.Ainf33 = 100;>> bemData.Khs33 = 20000;>> bemData.ss_rad33.A = [1 1;0 1];>> bemData.ss_rad33.B = [1;0];>> bemData.ss_rad33.C = [1 1];>> bemData.ss_rad33.D = 0;>> save -v7 bemData.mat
And the Modelica code I am using to try import this into MapleSim is as follows:
Modelica.SIunits.Mass M = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.m33",1,1)); Modelica.SIunits.Mass Ainf = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.Ainf33",1,1)); Modelica.SIunits.TranslationalSpringConstant C = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.Khs33",1,1)); Real A[2,2] = Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.A",2,2); Real B[1,2] = transpose(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.B",2,1)); Real C[1,2] = Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.C",1,2); Real D = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.D",1,1));
I then use these imported variables to solve ODEs, and the result is incorrect. I have narrowed it down to the fact that MapleSim/Modelica imports a value of 0 in place of the original data in the struct. Moreover, there is no way to attach a probe to any of the imported variables in MapleSim (I need to force all model variables to be displayed in the Simulation results tab).
I would appreciate help in pointing out where I might be making a mistake. My primary concern is why a value of 0 is being imported in place of the actual Matlab struct data. When I use Matlab's command window to check the contents of the struct, they appear to be in order.
Also, I have saved the struct file in the same folder in which my custom component is stored (the Modelica file where I have written the code to import the data). Should I be saving this file elsewhere?
Thank you!