Extract some data from a cell

7 ビュー (過去 30 日間)
Pol Auladell
Pol Auladell 2018 年 12 月 9 日
コメント済み: Pol Auladell 2018 年 12 月 9 日
Hi guys,
I have an array of strings, but somehow it's saved in a cell array like this:
dateList =
1×1 cell array
{9×1 cell}
My 9x1 cell is extracted from a txt file, so it could vary its length.
I want to withdraw some strings from that string array, for example
var=[1 3 6 7];
dateList(var);
Of course, it doesn't work since dateList is actually a 1x1 cell, not a 9x1 cell.
I have found the function cellfun, but what I want is not actually a function, and there's no "cell2string" function.
I have tried string(dateList) too, but the error message is the following:
Error using string
Conversion from cell failed. Element 1 must be convertible to a string scalar.
Is there a way to do it?

採用された回答

per isakson
per isakson 2018 年 12 月 9 日
編集済み: per isakson 2018 年 12 月 9 日
This typically happend when reading a text file with textscan. A simple solution is to insert
datelist = datelist{1};
before
dateList(var);
  1 件のコメント
Pol Auladell
Pol Auladell 2018 年 12 月 9 日
Thank you :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by