How to get user input into MatLab script called from Python script












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










share|improve this question























  • 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















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










share|improve this question























  • 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












0








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










share|improve this question














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







python python-2.7 matlab matlab-engine






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 27 '18 at 19:48









SPYBUG96SPYBUG96

4831623




4831623













  • 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





















  • 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



















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





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





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







@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






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507073%2fhow-to-get-user-input-into-matlab-script-called-from-python-script%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53507073%2fhow-to-get-user-input-into-matlab-script-called-from-python-script%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks