フィルターのクリア

Assign user-input as name of variable in for loop

1 回表示 (過去 30 日間)
John
John 2013 年 6 月 20 日
I want to write code that asks the user to open a file of data, then asks the user what they want to call it. Essentially I don't know how many files the user will have (between 2 and 10), and they all need to be distinguishable with a useful variable name.
My code first asks the user how many trials (data files) he plans to process, then runs the for loop that many times. In the for loop, it will ask the user to select the data file in question (completePath is a string of the location of the file), then prompts the user for a good variable name (TitleInput).
I want whatever TitleInput is to be assigned to the completePath string. That way those names can get assigned to graph labels, etc, automatically. Right now it simply replaces the completePath and TitleInput variables every time the for loop runs without saving previous data, so I only end up with the last file I import.
prompt = {'Enter number of trials to process'};
dlg_title = 'Trials';
num_lines = 1;
answer = inputdlg(prompt,dlg_title,num_lines);
[answer] = answer{:}; answer = str2num(answer);
for k = 1:answer
[Filename,Pathname,FilterIndex] = uigetfile('.c3d');
completePath = strcat(Pathname, Filename);
prompt = {'Name your trial'};
dlg_title = 'Trial name';
num_lines = 1;
TitleInput = inputdlg(prompt,dlg_title,num_lines);
[trialname] = TitleInput{:};
end
Help anyone?

採用された回答

per isakson
per isakson 2013 年 6 月 20 日
編集済み: per isakson 2013 年 6 月 20 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by