Ask the user first, but move on to the rest of the code immediately without waiting for a response

I am analyzing several different datasets which individually take some time. I need to enter a bunch of information for each dataset, but the information itself (a series of rows) is arbitrary and irrelevant for analysis. To save time in general, I want to initially present all of the original fields, but don't have to wait for the code to finish filling in all the information before proceeding with the analysis. Hopefully the example code below clarifies my goals.

%%%% Best code ever

% Select data file
filename = uigetfile

% Ask for information related to data set
info1 = input('Info1? = ','s');
info2 = input('Info2? = ','s');

% Load data and begin analysis without waiting for user response to inputs above
pause(1); % arbitrary time intensive process

% More code to display/save after inputs are entered data analysis finishes
plot(x,y)

%%%%

      

I had trouble finding similar topics because the only keyword / phrase I could come up with was "parallel processes", but that seemed to open up a much more complex worm program. The only luck I had was here , but it seemed too specific and I was lost as my coding abilities are random at best ...

+3


source to share


1 answer


The MATLAB interpreter is single-threaded, which means you can only do one thing at a time. I think your best option is to create a graphical interface (possibly with a GUIDE) for inputting information that the user could interact with while the other code is running. I'm afraid this is essentially the same solution as suggested in the question you linked to, I don't think there is a much easier way to do this.



+2


source







All Articles