i want to change [3,2,4](1x3 matrix) to 324(1x1 matrix) any help?

1 回表示 (過去 30 日間)
Hassaan Riaz
Hassaan Riaz 2018 年 11 月 16 日
編集済み: Bruno Luong 2018 年 11 月 16 日
i know i can do it by 3*100 + 2*20 + 4 but is there any cleaner method?

採用された回答

Guillaume
Guillaume 2018 年 11 月 16 日
編集済み: Guillaume 2018 年 11 月 16 日
polyval(yourvector, 10)
would also work
But what if your vector is [30, 20, 40]?
  1 件のコメント
Hassaan Riaz
Hassaan Riaz 2018 年 11 月 16 日
mine values will be ranging from 0-9. Thanks

サインインしてコメントする。

その他の回答 (2 件)

Bruno Luong
Bruno Luong 2018 年 11 月 16 日
>> str2double(char([3 2 4]+'0'))
ans =
324
>>

Bruno Luong
Bruno Luong 2018 年 11 月 16 日
編集済み: Bruno Luong 2018 年 11 月 16 日
This one produces NaN for overflowed data
>> polyval([3 2 4],10)
ans =
324
>> str2double(char([3 2 10]+'0'))
ans =
NaN

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by