Facebook
From A, 1 Month ago, written in Python.
This paste is a reply to Untitled from A - go back
Embed
Viewing differences between Untitled and Re: Untitled
Buonasera, sto cercando di runnare uno script MATLAB da Python e portare le variabili del workspace di MATLAB su Python. Faccio così:

# Run the main MATLAB script
eng.run('MAIN.m', nargout=0)

# Retrieve all variables from MATLAB workspace
variable_names = eng.eval('who()')

eval('who()')

# Iterate over variable names and retrieve their values
matlab_workspace = {}
for var_name in variable_names:
    var_value = eng.eval(var_name)
eval(var_name)
    matlab_workspace[var_name] = var_value

# Do something with the retrieved variables
for var_name, var_value in matlab_workspace.items():
    print(f"{var_name}: {var_value}")


print(f"{var_name}: {var_value}")


Ottengo questo errore:

var_value = eng.eval(var_name)
eval(var_name)
matlab.engine.EngineError: MATLAB function cannot be evaluated