subsindex error
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!