subsindex error

2 views (last 30 days)
Jan
Jan on 16 Apr 2012
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

Accepted Answer

Walter Roberson
Walter Roberson on 16 Apr 2012
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)

More Answers (0)

Categories

Find more on Data Type Conversion 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!