How do I access the values of the output arguments from "listing"? Where listing=dir(path,*.*)

When there is a single file involved the listing is a 1x1 structure array with field Names and descriptions. I need the info contained in the description.

Answers (1)

listing = dir(path, * . *) is no valid Matlab command. Please do not let us guess, what it should reply. The struct array replied by dir() does not contain the fields "Names" and "descritpions". Therefore you cannot obtain the information contained in the descritpion.
Please take the time to edit the question such that it gets clear what you have done so far and what you want to achieve.

3 Comments

Jan: I am trying to review some existing code. So your answer is not helpful because what I sent is exactly what is in the script. But my real question is how to index a structured array. Which I have found and understand now. Thanks.
Of course my answer could not be "useful", because it was not an answer but a question for clarification.
You have explained the real question much better in your comment. Asking good questions is a hard work, but this is the nature of question.
If it was exactly what was in the script it would have thrown an exception because the . was not enclosed in single quotes. It would have to be something like
listing = dir(fullfile(folder,'*.*'))
and, as you apparently found out there is no field called "description" exactly in that structure though there are fields for name, date, bytes, isdir, and datenum. Maybe you're looking for imfinfo() or something, but whatever - it sound like you have it solved (whatever you want to do).

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 11 Sep 2013

Community Treasure Hunt

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

Start Hunting!