so I make a vector:(adsbygoogle = window.adsbygoogle || []).push({});

V3 = [15.05:.05:15.15];

V3c = [14.75:.05:15.15];

find(V3c == Vc(2))

and I get nothing (no matches)

apparently, when matlab constructed V3, it did so such that:

V3(2) == 15.10000000000001

and

V3c(8) == 15.10000000000000

what's the deal?

My cheap way around this is:

V3 = fix(V3*1000)/1000

so I multiply by 1000, shave off the remaining decimals, and divide by 1000, but this doesn't seem robust to me. Is there a better way to handle this floating point difference?

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab floating point

Loading...

Similar Threads - Matlab floating point | Date |
---|---|

Python How can I run Python by getting values from Matlab | Mar 7, 2018 |

What is each step of this Matlab program doing? | Feb 21, 2018 |

C/++/# Help with MATLAB code? | Feb 9, 2018 |

Numerical Integration with variable limits MATLAB | Jan 15, 2018 |

Testing floating point numbers for equality | Jan 12, 2018 |

**Physics Forums - The Fusion of Science and Community**