0

I am trying to use the MATLAB scripts shipped with Dymola to post-process the output result of Dymola. But in some cases, the output data in the .mat file only have 2 elements, how could I get the data between 10s and 100s in this kind of cases?

It's a parameter or variable that is not time depending so it's stored in a compact way. I understand the mechanism, but it is not user-friendly when post-processing the data in MATLAB, I have to find the "wrong" dimensional data. How could I fix this issue?

enter image description here

Jack
  • 1,094
  • 6
  • 16
  • As you said, its a constant value. You could check if the parameter is constant and convert the 2 element array to a scalar value. Therefore you dont have to deal with the actual dimension of your data – f.wue Aug 04 '20 at 12:32

2 Answers2

1

I recommend creating some simple logic that looks at the size of the variable and then automatically puts it into some dictionary, list, etc. From there you can manipulate the variable. I know you are asking for Matlab but here is a Python solution that I have used which may help you get started:

    varNames_param_base=[]
    varNames_var_base=[]
    for i, val in enumerate(r.varNames()):
        if np.size(r.values(val)) == 4:
            varNames_param_base.append(val)
        else:      
            varNames_var_base.append(val)

I used those lines in this file.

In the example r.varNames() is a list of all the variable names (i.e., strings) which are read from the resulting Dymola .mat file. r.values gets the value of the variable name currently being used in the for loop (i.e., val).

Scott G
  • 2,194
  • 1
  • 14
  • 24
1

You may also consider converting your result file to SDF (a simple HDF5 representation), because that format does not use any clever storage options (if I remember correctly).

Dag B
  • 621
  • 3
  • 8