フィルターのクリア

inputting and array in command line format e.g. [2:2:10] etc

2 ビュー (過去 30 日間)
Ali
Ali 2012 年 11 月 16 日
Hello,
I am sure that this is possible. I want to accept some values from gui which would be the labels to a bunch of files, say run_001.txt run_003.txt run_005.txt ..... I want to have a gui edit box where I can type the array of values in the straight forward way one would do this on the commend line, roughly speaking (using my own Loadfile function) with array = (1:2:101)
for i:1:length(array) Cell{1,i} = Loadfile(strcat(filename,'_', array(i)),...); end;
Is it possible to format a string in the same way in the the gui and convert it to an array from the guy?
Thanks!

採用された回答

Matt J
Matt J 2012 年 11 月 16 日
編集済み: Matt J 2012 年 11 月 16 日
Yes. Just use
array = str2num( get(handles.EditBox,'String') );

その他の回答 (2 件)

Ali
Ali 2012 年 11 月 16 日
OK, straighrforward..... Need to use eval('[1:2:101]')
EVAL(s), where s is a string, causes MATLAB to execute the string as an expression or statement.

Ali
Ali 2012 年 11 月 27 日
Thanks for the answers and the never use eval warning, this seems to be a theme I noticed on further reading.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by