Clear Filters
Clear Filters

x=dir('c:\mydir') ; x(1).name = '49' ??? weird output bug

1 view (last 30 days)
Rory
Rory on 4 Dec 2011
Hi all
I was using the dir function to get a list of the subdirectories in a folder. Everything looks correct when I view the values of the output structure. However, when I want to assign the name values into a string array (to be used later as a loop indexer) the string values of the names that are assigned to my string array elements are all '49' ! This seems like something is not going right... I have tried using explicit loops and using : notation to assign the values but neither way works right.
Thanks in advance
  2 Comments
Sven
Sven on 5 Dec 2011
Can you show code beyond what's in the title of this post?
The code there indicates that you are *setting* the first element of the structure "x" to be the string '49'. Is this what you intended? Your question seems to be about doing something with a string array (rather than the structure output of "dir"), so it's a little unclear.
Jan
Jan on 5 Dec 2011
Without seeing the code, we cannot guess, what's going wrong.

Sign in to comment.

Answers (0)

Categories

Find more on File Operations 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!