Adding input command to standalone application.
Show older comments
Hi,
I have a 1600 line matlab script that requires several inputs from the user and based on them finds intercept, slope etc and puts them in an excel output file. Few excerpts of my code are below.
prompt = 'What is the input file name (with extension)? ';
inputFile = fullfile(input(prompt,'s'));
prompt = 'Enter 1 or 0';
loop_var = input(prompt);
while (loop_var)
prompt = 'Enter the name of variable you want to edit';
new_var = input(prompt,'s');
switch new_var
case 'slope_threshold'
fprintf('Current Value is %f \n', slope_threshold);
prompt = 'Enter new value';
residue_threshold = input(prompt);
%several other variable cases
end
prompt = 'If you have more variables to edit enter 1 else enter 0';
loop_var = input(prompt);
end
My code in command window of Matlab produces the following (user inputs are in bold):
What is the input file name (with extension)? abc.xlsx
Enter output file name, No spaces allowed: abc_output
What is the title of identifying column? Omit Spaces and enter any special chars as _ SERIAL_NO
What is the title of the x axis column? Omit Spaces and enter any special chars as _ TIME
What is the title of the y axis column? Omit Spaces and enter any special chars as _ Acceleration
What is the title of the Group column? Omit Spaces and enter any special chars as _ Group
Here are the parameters being used if you want to change any press 1 else press 0 1
My question is how do I do this in the stand alone application? I keep getting a runtime error if I just convert this m file into an app using the Application Complier.
5 Comments
awezmm
on 5 Aug 2019
What does the error say and are you getting this error while compiling or running? Also, how do you expect the user to type answers to the prompt? Did you make some sort of text input box for the GUI ?
Kriti Agarwal
on 5 Aug 2019
Joel Handy
on 5 Aug 2019
Edited: Joel Handy
on 5 Aug 2019
First I would investigate uigetfile and uiputfile. These are much better ways of having a user enter files to load and save.
You actually don't need fullfile either. That just concatenates parts of a file path. A user can only enter a single string with the input function. There is nothing to concatenate together.
Unfortunately, this doesn't actually answer your question though it may point you to some work arounds.
Kriti Agarwal
on 5 Aug 2019
Image Analyst
on 6 Aug 2019
You can use inputdlg() to enter in all your inputs in just one window - no nead to call it once for every input.
Answers (0)
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!