Help inserting character information into matrix
2 views (last 30 days)
Show older comments
Dan.Albrecht
on 9 Feb 2015
Commented: Dan.Albrecht
on 9 Feb 2015
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 Comments
Accepted Answer
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.
More Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!