inputdlg box to pass variables

2 views (last 30 days)
Jason
Jason on 6 Jun 2016
Commented: Jason on 6 Jun 2016
Hi. I am trying to run a piece of matlab code a variable number of times and to pass it a variable each time.
I thought the input dlg was a good way to go. So in the example I want to run my matlab code 5 times, and each time pass in the number in the 2nd box. so the first time 1000, 2nd time 2000 etc.
with my code as below. I can't quite finish what I need
prompt={'Enter the Number of Timelapses (exposure Times)',...
'Enter The expsoure times, comma seperated:'};
name='Input Timelapse - Multi Exposure';
numlines=1;
defaultanswer={'5','1000,2000,3000,4000,5000'};
answer=inputdlg(prompt,name,numlines,defaultanswer)
nExp=str2double(answer(1,:))
exps=answer(2,:)
I get the following.
nExp =
5.00
exps =
'1000,2000,3000,4000,5000'
How do I access each of the numbers on line 2? Is this the best way to do what I want to do?
(the number of values needed to pass isn't always 5, it will be any number of values)
Thanks
  1 Comment
Jason
Jason on 6 Jun 2016
I have tried this but with no luck:
C = strsplit(exps,',')

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 6 Jun 2016
Edited: Stephen23 on 6 Jun 2016
nExp = sscanf(answer{1},'%d,');
exps = sscanf(answer{2},'%d,');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!