How to use DIR function

조회 수: 3 (최근 30일)
Aadil
Aadil 2012년 9월 5일
I'm using this code:
MatFileDirectories = MatFileDirectories(1)
MatFileDetails = dir(MatFileDirectories)
but I get this error:
_??? Error using ==> dir
Function is not defined for 'cell' inputs._
Mat file directories is an array containing all the drive paths of the mat files:
MatFileDirectories = {
'C:\blahblah'
'C:\blahblah'
'C:\blahblah'
'C:\blahblah'
};
I don't get why it can't read the path from the array

채택된 답변

Image Analyst
Image Analyst 2012년 9월 5일
편집: Image Analyst 2012년 9월 5일
Common mistake, use braces instead of parentheses:
MatFileDirectories = MatFileDirectories{1};
In general, anytime you have problems with cell arrays, switch from () to {}, or from {} to (). Chances are, one of them will work. Another useful tip is to learn about the cell2mat() and char() functions.
  댓글 수: 1
Aadil
Aadil 2012년 9월 5일
My God, I was putting the blummin brackets in the Dir{} function
Facepalm
Thanks a load

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by