Integer division problem (gear ratio related)

조회 수: 7 (최근 30일)
Jimmy W
Jimmy W 2016년 10월 24일
답변: KSSV 2016년 10월 24일
Let's say A/B = 2.417. A and B both must be integers. I need to write a script to list some possible combos of A and B. Also 2.417 is a gear ratio rounded up to 4 significant figures, so it doesn't have to be exactly 2.417, but A and B must be something practical like 1-100. Any help would be greatly helpful!

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 24일
V = 1 : 100;
[A,B] = ndgrid(V);
R = A./B;
match = R > 2.416 & R < 2.418;
results = [A(match), B(match), R(match)]

추가 답변 (1개)

KSSV
KSSV 2016년 10월 24일
A = linspace(1,100) ;
B = A/2.417 ;
[A' B']

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by