Open chaohcc opened 3 years ago
Can you describe your problem in a bit more detail and provide some example code so we can reproduce it?
Can you describe your problem in a bit more detail and provide some example code so we can reproduce it?
Thank you!
import transplant
matlab = transplant.Matlab()
res = matlab.Myfun(data,para)
Y = res[0]
A= res[1]
the code above is run correct,and start a matlab session, and run my matlab function "Myfun(data,para)", and return the result of matlab to python.
My question is how should I use code or command in python to close the matlab session?
Now the matlab session can't close itself, I need close it's window manually, and if the matlab session didn't close, the python code after the matlab session will not run. In other words, the code,
Y = res[0]
A= res[1]
would run after I close the matlab session manually.
Sorry, my English is poor, hope I have made it clearly, thank you!
If I understand you correctly, your Myfun
does not return? That would be a problem in Myfun
, not Transplant.
However, you say "I need to close its window manually", which implies that you are doing graphical things inside Myfun
. This can be tricky within Transplant, as Transplant does not / can not drawnow
every so often, which some Matlab code requires. You can try adding a few drawnow()
to your Myfun
and see if that helps.
If I understand you correctly, your
Myfun
does not return? That would be a problem inMyfun
, not Transplant.However, you say "I need to close its window manually", which implies that you are doing graphical things inside
Myfun
. This can be tricky within Transplant, as Transplant does not / can notdrawnow
every so often, which some Matlab code requires. You can try adding a fewdrawnow()
to yourMyfun
and see if that helps.
Thank you! my problem is my python code start matlab successfuly and open a matlab window, run Myfun correctly. but python code not continus until the matlab window closed . seems the matlab.exit() methed is not working.
What sort of Matlab window is being opened? Like a figure? What operating system are you running?
What sort of Matlab window is being opened? Like a figure? What operating system are you running? Thank you! here is the code I start matlab
I run on Windows10. The opened Matlab window is like the following picture:
Best wishes! Thank you!
Is that Window interactive, i.e. can you type something in there and get a response? That shouldn't happen.
Could you debug into your transplant_master.py, and report back the value of process_arguments
in line 568?
Is that Window interactive, i.e. can you type something in there and get a response? That shouldn't happen.
Could you debug into your transplant_master.py, and report back the value of
process_arguments
in line 568?
Thank you! Yes, I can type something in window and it will run and give a response. I debug transplant_master.py, the value of process_arguments
:
Thank you!
If there is a window, it should not be interactive. If it is interactive, transplant must have crashed. It's a sad fact of Matlab that some errors can't be caught. Do you see any error messages that might indicate a crash of transplant_remote?
If there is a window, it should not be interactive. If it is interactive, transplant must have crashed. It's a sad fact of Matlab that some errors can't be caught. Do you see any error messages that might indicate a crash of transplant_remote? Thank you! I haven't see any error messages that might indicate a crash of transplant_remote. Is there any way to see it or debug?
The errors should show up either in your Python console, or in Matlab's window. Although since you seem to be running inside an IDE, perhaps the IDE is eating STDERR?
Perhaps you will see an error if you try running your program in a plain terminal instead of an IDE.
The errors should show up either in your Python console, or in Matlab's window. Although since you seem to be running inside an IDE, perhaps the IDE is eating STDERR?
Perhaps you will see an error if you try running your program in a plain terminal instead of an IDE. okey, thank you so much, I will have a try running my program in a plain terminal.
Hello, I have the same issue here -I use the transplant module on windows to call Matlab functions in Python but can't get rid of the command window that pop up neither exit the Matlab session-, has anyone found a solution.
edit:
eng.quit()
does close the command window but raises "RuntimeError: Process died unexpectedly"
eng.close()
returns 1 but doesn't do anything
eng.exit()
requires me to write in the matlab command ">> exit()" too to close the session
Thanks in advance.
It may be that matlab on Windows behaves differently from matlab on unices. Try inserting exit()
into https://github.com/bastibe/transplant/blob/master/transplant/transplant_remote.m#L37 and see if that helps.
I use python code: matlab.close(); matlab.exit(); matlab.send_message('die'), it seems does't work. Thank so much!