Multiple prompt/input with inputdlg according to a value

30 views (last 30 days)
Hi everybody, I am at the "visual" stage of my program and I want to simplify the input process.
The program works with a variable amount of colors which changes depending on the image that is analyzed.
After that, the user must introduce manually two treshhold values MIN/MAX for each color.
I would like to use inputdlg() to display as much prompt/inputs as needed according to the "colors" value.
Here a self made image of what I would like to have:
Thank you in advance.
  5 Comments
madhan ravi
madhan ravi on 5 Jun 2020
Yes I was interpreting in another way xD. Nevertheless I admire the terms you use often.
dpb
dpb on 5 Jun 2020
OK...just in case you didn't realize there was one in the arsenal... :)
"I admire the terms you use often."
Indeed, I don't see any point in not having a little fun and humor along the way! Glad somebody sees similarly.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 5 Jun 2020
Something like this
num_colors = 4;
prompts = cell(1, num_colors*2);
prompts(1:2:end) = compose('Enter min value for color %d', 1:num_colors);
prompts(2:2:end) = compose('Enter max value for color %d', 1:num_colors);
out = inputdlg(prompts)
  1 Comment
Gonzalo Molina
Gonzalo Molina on 5 Jun 2020
Hello again Ameer, it was really useful.
Here is what I've done to display a dialog for each one.
for i= 1:colors
prompt2 = compose('Enter MIN value for color %d', i);
content_coords(i,4) = eval(char(inputdlg(prompt2,dlgtitle1,dims1,definput)));
prompt3 = compose('Enter MAX value for color %d', i);
content_coords(i,5) = eval(char(inputdlg(prompt3,dlgtitle1,dims1,definput)));
end
Thank you.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!