필터 지우기
필터 지우기

Matlab code for fractions

조회 수: 95 (최근 30일)
Johnny McKenney
Johnny McKenney 2020년 9월 27일
댓글: Star Strider 2020년 9월 27일
How would I write 1.5/s as a num[ ] den[ ] code in matlab?

채택된 답변

John D'Errico
John D'Errico 2020년 9월 27일
Confusing question.
Do you know the value of s?
s = 7
s =
7
>> 1.5/s
ans =
0.214285714285714
>> format rat
>> 1.5/s
ans =
3/14
Do you not know what is is, so you want to use s in a symbolic form?
syms s
1.5/s
ans =
3/(2*s)
  댓글 수: 1
Johnny McKenney
Johnny McKenney 2020년 9월 27일
I do not know S. I think it is 1. We are meant to write
numx = [ 1 2 3]
denx = [1 2 3]
as an example. I just can't figure out how to do that with 1.5/S or 1/S+2

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Star Strider
Star Strider 2020년 9월 27일
Use the rat function:
x = 1.5
[num,den] = rat(x)
producing:
num =
3
den =
2
.
  댓글 수: 2
Johnny McKenney
Johnny McKenney 2020년 9월 27일
ok thank you
Star Strider
Star Strider 2020년 9월 27일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by