How to use DIR function

1 Ansicht (letzte 30 Tage)
Aadil
Aadil am 5 Sep. 2012
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

Akzeptierte Antwort

Image Analyst
Image Analyst am 5 Sep. 2012
Bearbeitet: Image Analyst am 5 Sep. 2012
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 Kommentar
Aadil
Aadil am 5 Sep. 2012
My God, I was putting the blummin brackets in the Dir{} function
Facepalm
Thanks a load

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by