subsindex error

2 次查看(过去 30 天)
Jan
Jan 2012-4-16
In this piece of script I am trying to use a shortcut adapted from another script so that I don´t have to write out each file name I want to import.
%open right path
cd (PATHIN)
%read in all -vhdr files
list=dir('*.vhdr');
len=length(list);
SUBJ=cell(1,len);
Here I check what SUBJ is and get [] [] as the answer...So then I start the for loop to read in the data:
for s=1:len(SUBJ)
And it gives me an error which says- Error using subsindex. Function ´subsindex´ is not defined for values of class ´cell´.
I am guessing that when I write
len=length(list);
I am converting the list into a numerical value of the number of files so that are in the directory. What should I write instead?
Thanks in advance for the help! JD

采纳的回答

Walter Roberson
Walter Roberson 2012-4-16
You are trying to access your scalar variable "len" at an index which is a cell array "SUBJ".
If you meant length(SUBJ) instead of len(SUBJ) then you might as well use
for s=1:len
since you have already assigned len to be length(SUBJ)

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by