LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Mellobuck

Convert float to rational approximation

Status: Declined

Any idea that has received less than 5 kudos within 5 years after posting will be automatically declined.

I would like to see a LabVIEW implementation of the Matlab function which approximates a floating point number to a ratio of two integers, within a given tolerance.

From Matlab help:

 RAT    Rational approximation.
    [N,D] = RAT(X,tol) returns two integer matrices so that N./D
    is close to X in the sense that abs(N./D - X) <= tol*abs(X).
    The rational approximations are generated by truncating continued
    fraction expansions.   tol = 1.e-6*norm(X(:),1) is the default.
 
    S = RAT(X) or RAT(X,tol) returns the continued fraction
    representation as a string.

 

Some discussion and example code of how to implement in LabVIEW is here: http://forums.ni.com/ni/board/message?board.id=170&thread.id=18012&view=by_date_ascending&page=2

 


Data Science Automation

CTA, CLA, CLED
SHAZAM!
2 Comments
jattas
Member
This is available in MathScript via the rat function. But I agree that it would be nice to have a pure LabVIEW version.
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 5 kudos within 5 years after posting will be automatically declined.