Help inserting character information into matrix
1 次查看(过去 30 天)
显示 更早的评论
Hey everyone, pretty new user here, so I'm probably overlooking an easy solution. I'm trying to extract subject information (subject name=character and weight=number) into a two column matrix. Below is the code I've been trying to use:
Code
list=dir('C*0*');
weights={}
for m=1:length(list)
cd(fullfile(list(m).name,'MR','MPRAGE'));
dcmlist=list('*.dcm');
A=dicominfo(dcmlist(m).name);
weights{m,1}=list(m).name
weights{m,2}=A.PatientWeight
if true
% code
end
clear A
end
What I can't understand, is that when I do this manually (insert one variable into the matrix at a time) it seems to work, but when I evaluate the code as a whole, I get the "matrix dimensions exceeded" error. I've tried creating separate empty cell matrices for subject name and weight, and also changed the way the data is appended (from {m,1} to {1,m}), all to no avail. Any help is greatly appreciated!
0 个评论
采纳的回答
Image Analyst
2015-2-9
What do you think this is supposed to do:
dcmlist=list('*.dcm');
??? list is a cell array of strings . It takes an index like 1,2,3,4, not a wildcard string.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!