How can I merge vector elements into a single number of type double?
15 ビュー (過去 30 日間)
古いコメントを表示
Hello,
How can I transform this vector:
v=[1 2 3]
into this scalar of type double?:
k=123
Thank you,
Lazaros.
0 件のコメント
採用された回答
その他の回答 (2 件)
YT
2019 年 2 月 4 日
編集済み: YT
2019 年 2 月 4 日
Something like this?
A = [1 2 3];
joined = str2num(strjoin(num2cell(num2str(A(:))),''));
%>> joined = 123 (type double)
There are probably some more elegant solutions, but this is what I came up with for now.
3 件のコメント
Guillaume
2019 年 2 月 5 日
Indeed but that is most likely the case I assume.
A simpler, yet more generic solution, using number->string->number conversion:
str2num(strjoin(compose('%d', A), ''))
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!