Info
此问题已关闭。 请重新打开它进行编辑或回答。
why am I having problems with a string and vector and how to use a *?
2 次查看(过去 30 天)
显示 更早的评论
hello!
i am trying to load a bunch of .txt files that are in different subject folders, but when i try to run the script with more than one subject, i get errors saying 'Must be a string scalar or character vector'.
The data is all in folders:
/Users/ll/Documents/data_analysis/HCP/seventy/HCA*/ts/cortex.txt
The only changing aspect is the subject number, and I can't figure out how to make it a variable. I have a ton of subjects to do analysis, so it would be great if i didn't indiviudally have to put the subject name in. Does anyone have any ideas? Thanks so so much.
My code:
subj = {'HCA1','HCA2'}; %HCPsubj list
for a = 1:numel(subj)
(subj{a})
end
D = ['/Users/ll/Documents/data_analysis/HCP/seventy/', subj];
for k = 1:2
name = sprintf('ts',k); % HCA1, HCA2, etc.
l = load(fullfile(D,name,'lcortex_run01regPA.txt'));
v = load(fullfile(D,name,'ventricle_run01regPA.txt'));
s = load(fullfile(D,name,'spinal_run01regPA.txt'));
0 个评论
回答(1 个)
Walter Roberson
2019-12-29
subj = {'HCA1','HCA2'}; %HCPsubj list
D = '/Users/ll/Documents/data_analysis/HCP/seventy/';
for k = 1:length(subj)
name = subj{k};
l = load(fullfile(D,name,'lcortex_run01regPA.txt'));
v = load(fullfile(D,name,'ventricle_run01regPA.txt'));
s = load(fullfile(D,name,'spinal_run01regPA.txt'));
...
end
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!