Cell to String

10 views (last 30 days)
Ajay Kumar
Ajay Kumar on 7 Mar 2012
Hi,
I am trying to concatenate a two strings in the below code:
baseDIR = 'C\Documents and Settings\User\Desktop\';
tstFeats = {'PostEq', 'AEC'};
refDir = strcat(baseDIR, tstFeats);
fileList = dir([refDir '\*.wav']);
the command dir does not work on input of type cell. I would like to convert the type cell to string to enable the working of the above code.
If I replace tstFeats = {...} with tstFeats = [...], the code works fine. But all elements in the second case need to be of the same length if I need to make a column vector.
Any help is appreciated.
Thank you.

Answers (1)

Walter Roberson
Walter Roberson on 7 Mar 2012
There does not seem to be much point in this, as dir() can only accept a single specification per call.
Please also recall that the structure of information returned by dir() does not indicate the directory anywhere, so if you did somehow manage to get dir() to look in two directories on the same call, you would not be able to tell which directory any particular returned file name had come from.
  2 Comments
Ajay Kumar
Ajay Kumar on 8 Mar 2012
Hello Walter. Nice to hear from you :)
Actually, I have the above in a for-loop which considers one folder at a time. It would be very helpful if there is any kind of work around and will save me a lot of time.
It would sufficient if I could have the following work:
a = {'ab', 'abc'};
b = a(1);
Now variable b should be assigned as a string and should not hold values as a cell.
The work around I thought of:
a = ['abc'; 'def']; % Column vector with all rows of same size
b = a(1,:);
Now b is a string. But, in this method I will not have the flexibility of choosing different sizes for the elements in Column matrix a.
Walter Roberson
Walter Roberson on 8 Mar 2012
b = a{1}

Sign in to comment.

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!