entering fraction

##### Title

##### Question

sir, while doing the second exercise, I encountered a problem in \r\nprinting the fractions. while entering the elements of the matrix I \r\nentered the fractions but got the results as decimals.

I want to get the fractions as output. please guide me in the same.

I want to get the fractions as output. please guide me in the same.

Scilab Vector-Operations 05-06 min 40-50 sec

__Answers:__

You will have to use the rat function. Examples are given below

n- numerator, d- denominator

[n,d]=rat(2/3)

d =

3.

n =

2.

-->a=[1/2;4/5;6/7]

a =

0.5

0.8

0.8571429

-->[n,d]=rat(a)

d =

2.

5.

7.

n =

1.

4.

6.

->[n,d]=rat(0.1/5)

d =m

50.

n =

1.

If you want to display the output strictly in the form numerator/denominator (with the division symbol), then you would have to install the Symbolic toolbox.

n- numerator, d- denominator

[n,d]=rat(2/3)

d =

3.

n =

2.

-->a=[1/2;4/5;6/7]

a =

0.5

0.8

0.8571429

-->[n,d]=rat(a)

d =

2.

5.

7.

n =

1.

4.

6.

->[n,d]=rat(0.1/5)

d =m

50.

n =

1.

If you want to display the output strictly in the form numerator/denominator (with the division symbol), then you would have to install the Symbolic toolbox.

Login to add comment