Transform char variable to matrix
古いコメントを表示
Hi, I have a cell variable that looks like this:

I'D like to know if there is a way to transform it into a matrix of this kind:
NewVar=[2 5; 2 3; 2 5];
Thanks
採用された回答
その他の回答 (2 件)
Stephen23
2020 年 2 月 15 日
Efficient solution:
>> C = {'002,005';'002,003';'002,005'};
>> sscanf(sprintf('%s;',C{:}),'%f,%f;',[2,Inf]).'
ans =
2 5
2 3
2 5
Sindar
2020 年 2 月 14 日
tmp={'002,005';'002,003';'002,005'};
NewVar=str2double(split(tmp,','))
2 件のコメント
Guido Pozzi
2020 年 2 月 14 日
Sindar
2020 年 2 月 14 日
strsplit might work, but you might need to loop over cells
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!