creating new number from two numbers
古いコメントを表示
if i need to create a new number from two given numbers for example : a=4 b=9 new number should be a times b (9999). is there a command to do that ?
採用された回答
その他の回答 (2 件)
Guillaume
2014 年 12 月 2 日
Using conversion to string and back this is easy but maybe not fast:
repeat = 3;
number = 12;
repeatednumber = str2num(repmat(num2str(number), 1, repeat))
1 件のコメント
Guillaume
2014 年 12 月 2 日
Or staying exclusively numeric:
repeat = 3;
number = 12;
temp = repmat(number, 1, repeat);
repeatednumber = sum(temp .* 10.^((numel(temp)-1:-1:0)*(1+floor(log10(number)))))
Andrei Bobrov
2014 年 12 月 2 日
編集済み: Andrei Bobrov
2014 年 12 月 2 日
sum(10.^(a-1:-1:0)*b)
or
polyval(b*ones(1,a),10)
add
polyval(b*ones(1,a),10^ceil(log10(b)))
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!