フィルターのクリア

Splitting a real number into several integers depending on position.

2 ビュー (過去 30 日間)
Lewis
Lewis 2019 年 6 月 18 日
コメント済み: Lewis 2019 年 6 月 18 日
Good afternoon guys,
This seems abit confusing, but this is what i am trying to accomplish.
If i have x=0.4321
I need a way to split this real number into just single integers, so for example
x1=0, x2=4, x3=3.... and so on, with the number after the 'x' corresponding to its position in the original real number.
is there a way to do this?
To give a wider context, i will have a f(x) = 0.AB rounded down to 2dp. The actual values of A and B are the coordinates to find a value within a large matrix.
Thanks in advance for any help!

採用された回答

Bob Thompson
Bob Thompson 2019 年 6 月 18 日
Why not turn the number into a string?
y = num2str(x);
y = y(y(:)~='.'); % Remove '.'
With this you are left with the numbers following the decimal, and if you would like to call them one at a time then you can just index y.
Y = str2num(y(3));

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by