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!

采纳的回答

Image Analyst
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.
  1 个评论
Dan.Albrecht
Dan.Albrecht 2015-2-9
Yeah, nothing. That was my fault, it was supposed to be dcmlist=dir('*.dcm'). Works just fine now. Thanks for catching my stupid syntax error!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by