inputdlg box to pass variables

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

 采纳的回答

Stephen23
Stephen23 2016-6-6
编辑:Stephen23 2016-6-6
nExp = sscanf(answer{1},'%d,');
exps = sscanf(answer{2},'%d,');

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by