Please how do i convert a cell array like a ={'1','2','3','4','5','6','7','8','8'}; to be b = [1 2 3 4 5 6 7 8 8]. I tried the function cell2mat but it didnt give me b = [1 2 3 4 5 6 7 8 8].
Thanks

 採用された回答

Jan
Jan 2019 年 5 月 22 日
編集済み: Jan 2019 年 5 月 22 日

3 投票

a ={'1','2','3','4','5','6','7','8','8'};
n = str2double(a)
This can be faster under some conditions:
n = sscanf(sprintf('%s ', a{:}), '%d').'
cell2mat converts the cell array of char vectors to a char matrix. But this does not convert the char vectors to numbers.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

タグ

質問済み:

2019 年 5 月 22 日

編集済み:

Jan
2019 年 5 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by