I want to save a workspace variable from the matlab code itself. I am able to save the workspace variable using save command in command window but I do not want to give any command in the command window . I want to save the workspace vaiable with a command given in the matlab code itself. I tried save command or matlab.io.saveVariablesToScript() in the matlab code but it gives the error variable 'ans' not found ('ans' isthe workspace variable I want to save).
I am running this matlab code from python using matlab.engine so I can not give any command in the command window.
I want to know three things.
1) Can I save a workspace variable from python after it's run?
2) Can I save workspace variable from the command given in the matlab code itself?
3) Can I give which command needs to be run in the command window from the matlab code itself?
I tried first two but they gave the error. I have no idea about the third one.
Can somebody help me please?