Facebook
From A, 1 Month ago, written in Python.
This paste is a reply to Untitled from A - view diff
Embed
Download Paste or View Raw
Hits: 173
  1. Buonasera, sto cercando di runnare uno script MATLAB da Python e portare le variabili del workspace di MATLAB su Python. Faccio così:
  2.  
  3. # Run the main MATLAB script
  4. eng.run('MAIN.m', nargout=0)
  5.  
  6. # Retrieve all variables from MATLAB workspace
  7. variable_names = eng.eval('who()')
  8.  
  9. # Iterate over variable names and retrieve their values
  10. matlab_workspace = {}
  11. for var_name in variable_names:
  12.     var_value = eng.eval(var_name)
  13.     matlab_workspace[var_name] = var_value
  14.  
  15. # Do something with the retrieved variables
  16. for var_name, var_value in matlab_workspace.items():
  17.     print(f"{var_name}: {var_value}")
  18.  
  19.  
  20. Ottengo questo errore:
  21.  
  22. var_value = eng.eval(var_name)
  23. matlab.engine.EngineError: MATLAB function cannot be evaluated