Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Zeolite
  • » Profile

Posts

Posts

Hello! I'm using following python script to get variables from *.mat result file:

Code:


import OMPython as omp
result_dict = {}
# read all names of variables from "res_filename"
res = omp.execute('readSimulationResultVars("'+res_filename+'")')
# create list of variables' names
temp_vars_list = omp.get(res, 'SET1.Values')[0].split(',')
# delete first and last " symbols
vars_list = [variable[1:-1] for variable in temp_vars_list]
for key in vars_list:
    values_list = omp.execute('readSimulationResult("'+res_filename+'", '+key+')')
    # delete last value ([:-1]), because it is the same as penultimate
    result_dict[key] = omp.get(values_list, 'SET2.Set1')[:-1]
    omp.execute('closeSimulationResultFile()')

This code worked well for dcmotor model, but with linear_actuator model it fails to retrieve values for such variables that have brackets, i.e. "(" or ")",  in their names.
For example:
variable der(der(mass1.flange_b.s)) or
variable der(der(idealgearr2t1.flangeT.s))

Is it possible to get values of variables with such names?
I tried these:

Code:


readSimulationResult("results.mat", 'der(der(idealgearr2t1.flangeT.s))')
readSimulationResult("results.mat", "der(der(idealgearr2t1.flangeT.s))")
readSimulationResult("results.mat", {der(der(idealgearr2t1.flangeT.s))})

Nothing worked.

  • Index
  • » Users
  • » Zeolite
  • » Profile
You are here: