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()')
# Iterate over variable names and retrieve their values
matlab_workspace = {}
for var_name in variable_names:
var_value = eng.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}")
Ottengo questo errore:
var_value = eng.eval(var_name)
matlab.engine.EngineError: MATLAB function cannot be evaluated
Replies to Untitled
Title |
Name |
Language |
UNIX |
When |
Re: Untitled |
A |
python |
1715979571 |
1 Month ago. |
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}