Help inserting character information into matrix

2 views (last 30 days)
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!

Accepted Answer

Image Analyst
Image Analyst on 9 Feb 2015
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 Comment
Dan.Albrecht
Dan.Albrecht on 9 Feb 2015
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!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!