The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to eliminate the zeros from a number
Replies: 4   Last Post: Aug 14, 2014 6:29 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 2,359
Registered: 12/6/04
Re: How to eliminate the zeros from a number
Posted: Aug 14, 2014 4:04 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Andrea Clerico" <> wrote in message <lsj2aq$n3o$>...
> Hello everyone,
> I am experiencing a problem with the same number but written in two different ways.
> In a function that I am writing I have to use the function 'floor' for a vector. The result is that the numbers are written in this way:
> A = [0.5000000000000,0.6000000000000000,0.700000000000000,0.80000000000000,0.9000000000000000,1.0000000000000000];
> Once done that, I have to use the function 'intersect' with the vector
> B = [0,1,2,3,4,5,6,7,8,9,10];
> to understand how many and which elements they have in common.
> The problem is that Matlab thinks that the numbers
> 1.000000000000000000000 and 1 are different.
> How can I solve this problem??
> Thank you very much for your help.
> Andrea

You may want to take a look at this link from the MATLAB FAQ:


Do you really have to use intersect? Although intersect works with numeric arrays, the examples shown in

doc intersect

are only for integers.

The above link shows how to compare floating point numbers that are "close enough" if that helps.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.