math operation

1 次查看(过去 30 天)
sam arf
sam arf 2012-4-4
Hi, I have some problem here,
case1, a=7, b=4, a/b = 1.75
case2, a=3, b=2, a/b = 1.5
I want variable "c" to become decimal value of a/b,
c = 0.75 (for case 1), and c = 0.5 (case 2)
wich matlab operation should I use?

采纳的回答

Jan
Jan 2012-4-4
a = 7;
b = 4;
c = rem(a / b, 1)
or
c = a / b;
d = c - floor(c);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by