Cell to String

12 ビュー (過去 30 日間)
Ajay Kumar
Ajay Kumar 2012 年 3 月 7 日
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.

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 3 月 7 日
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 件のコメント
Ajay Kumar
Ajay Kumar 2012 年 3 月 8 日
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 2012 年 3 月 8 日
b = a{1}

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by