converting array to single
古いコメントを表示
i have this output:
output = dial ('1FUNDOG4YOU')
output =
1 3 8 6 3 6 4 4 9 6 8
(1 X 11) cell
but this is what i want
output :13863644968
(1X 1)
I've tried all sort of ridiculous stuff, str2num and the likes but nothing works . any idea on what to do to make the conversion happen? thanks
採用された回答
その他の回答 (1 件)
Walter Roberson
2016 年 6 月 14 日
Be careful, str2num() will create double precision with only 53 bits of precision. If you need the full 64 bits of precision you will need a different calculation.
C = {1,3,8,6,3,6,4,4,9,6,8};
Cv = uint64([C{:}]);
output = sum( Cv .* (uint64(10).^uint64(length(Cv)-1:-1:0)), 'native' );
6 件のコメント
OLUBUKOLA ogunsola
2016 年 6 月 15 日
OLUBUKOLA ogunsola
2016 年 6 月 15 日
The function isstrprop and all both return logical values, so you don't need to compare them to anything. They are already boolean values, that can be used directly in an if statement:
if all(isstrprop(...))
...
else
...
end
No testing for "==0" is required.
OLUBUKOLA ogunsola
2016 年 6 月 15 日
OLUBUKOLA ogunsola
2016 年 6 月 15 日
編集済み: Walter Roberson
2016 年 6 月 15 日
カテゴリ
ヘルプ センター および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!