0x1 matrix getting while using find function
Ältere Kommentare anzeigen
Am getting 0x1 matrix while using find function to retreiv the indices,i have tried to use the max function in the array and then used find function still getting 0x1 empty double matrix error.Could you please help as when am using the same function to retriev the other indices am getting proper results
6 Kommentare
KALYAN ACHARJYA
am 10 Sep. 2018
What is 0x1 matrix?
Sandeep Nair
am 10 Sep. 2018
Well, if you're getting an empty matrix it's because find didn't find anything. If you were expecting find to find something, then you've got a bug (or the wrong expectations) but without seeing your code we certainly can't guess what the bug could be.
Sandeep Nair
am 10 Sep. 2018
You are doing an exact comparison of floating point numbers, which is not recommend because of the exact problem that you are having. Always compare the difference of floating point numbers against a tolerance:
abs(A-B)<=tol
The values that you are trying to compare cannot be exactly represented using binary floating point numbers, and are not the same. What you see printed in the command window is the closest representation to 5 or 16 significant digits, depending on your current format setting. To see the "real" value download James Tursa's FEX submission:
Use James Tursa's num2strexact and you will see that none of those values really have the exact value 2.11. All you are looking at is a representation of those floating point numbers displayed in the command window, to the precision defined by your format setting. Just because you see 2.11 displayed tells you nothing about the "real" floating point number's value.
You need to learn about the limits of floating point numbers. Start by reading these:
This is worth reading as well:
Sandeep Nair
am 10 Sep. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Linear Algebra finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!