フィルターのクリア

How can I create a new cell array from an existing one?

2 ビュー (過去 30 日間)
Chris Stillo
Chris Stillo 2020 年 5 月 27 日
コメント済み: Stephen23 2020 年 5 月 28 日
Hi,
I have this:
Country =
{
[1,1] = "SUB-SAHARAN AFRICA"
[2,1] = "Eastern Africa"
[3,1] = "Burundi"
[4,1] = "Comoros"
}
But I need to strip out the quotes like this:
Country_new = {}
Country_new = {}(0x0)
>> Country_new(1) = Country{1}(2:end-1)
Country_new =
{
[1,1] = SUB-SAHARAN AFRICA
}
>> Country_new(2) = Country{2}(2:end-1)
Country_new =
{
[1,1] = SUB-SAHARAN AFRICA
[1,2] = Eastern Africa
etc
But when I try:
Country_new(3:4) = Country{3:4}(2:end-1)
error: a cs-list cannot be further indexed
I just need a one liner to do the job on each of the elements all at once. I tried with a for loop:
Country_new = {}
for a = 1 : numel(Country)
Country_new(a) = Country{a}(2:end-1);
end
but I don't think it's right because it seems to take too long.
Thanks

採用された回答

Stephen23
Stephen23 2020 年 5 月 27 日
Country = strrep(Country,'"','')
  2 件のコメント
Chris Stillo
Chris Stillo 2020 年 5 月 27 日
Thank you so much
Stephen23
Stephen23 2020 年 5 月 28 日
@Chris Stillo : I hope that it helps. Please remember to accept my answer!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by