0

I am calling a MatLab script from a python script and my MatLab script requires user input. When I am prompted for input the terminal doesn't allow input. Am I able to get user input into the MatLab function when I run the function from python? How would you do this?

Python:

import matlab.engine
import time
from datetime import datetime
import thread
import threading

eng = matlab.engine.start_matlab()
eng.easyRun(20181116,nargout=0)
eng.quit()
print "Python script complete"

MatLab:

function easyRun(dateInput)

disp('-------------------------')
disp('Plot Types:')
disp('1 - x,y,z')
disp('2 - Magnitude')

%This is where I am asking for user input
plotType = input('Enter plot type # (1-2): ');

disp(plotType)
disp(dateInput)

end

For example an input of 1 will result in an output of:

1

20181116

This is part of a bigger program where I am multi-threading a MatLab function so I can process a week of data all at the same time, but that part is not needed for this question

Community
  • 1
  • 1
SPYBUG96
  • 1,089
  • 5
  • 20
  • 38
  • I have a feeling I'll need to split up the MatLab function and ask for the user input in python then send it to another MatLab function to continue the task :/ – SPYBUG96 Nov 27 '18 at 20:06
  • Why not ask for the user input in python before calling the Matlab function, and provide this as an additional argument to the function? – rinkert Nov 27 '18 at 20:40
  • @rinkert This is just a simple example of what I want to be able to do. I need to get user input to remove certain bad data sections of a plot which displays, so the user wont know what to put until they reach this spot. It works in MatLab, but I can't multithread MatLab to run a variable number of processes of the same code at the same time on different cores – SPYBUG96 Nov 27 '18 at 20:43

0 Answers0