Extracting numerator and denominator values from a decimal value

13 views (last 30 days)
I want matlab to automatically extract numerator and denominator values from a decimal value when I enter one.
For example, I entered a value R (Variable) = 6.52 , so matlab should automatically assign L (Numerator) = 652 and M (Denominator) = 100 .
Basically, I'm doing Resampling in Digital Signal Processing course, and whenever I enter the value of resampling factor, I want matlab to automatically extract Interpolation (L) and Decimation (M) factors from that value, for further processing (manual resampling).

Accepted Answer

Stephen23
Stephen23 on 4 Dec 2021
[N,D] = rat(6.52)
N = 163
D = 25
Multiply both by four if you want to.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!