Find function not working when trying to look for a big number

Hello everyone, I have 2 matrices with the first column in each matrix which has the key records which link both the matrices. I'm trying to take "M_rec_qty_1" as my base matrix and trying to use the find function to check the records from each row in the first column to be present in the first column of "final_matrix".
If i find it, then i insert the row number, column number and the data i found in to one more matrix "pos_data_matrix", for further use in the code.
But the problem seems to be that the data i'm looking in final_matrix is really big.. for example... "5642007779", so when find tries to use this data it converts it into 5.642 * 10^9 and hence is not able to find an exact match and brings more vales in the same range. because of which the logic doesn't work. Can someone please help solving this issue.
Please find the for loop which i sue in the code below.
for m1r = 4:1000
[rownum,colnum] = find(final_matrix==M_rec_qty_1(m1r,1))
pos_data_matrix(m1r-3,1) = rownum;
pos_data_matrix(m1r-3,2) = colnum;
pos_data_matrix(m1r-3,3) = M_rec_qty_1(m1r,1);
endfor
Thanks Raj

3 Comments

Are you sure you have an integer or is it something like 5642007779.000001.
Hello Daniel, The numer are whole numbers... there are no decimal points... the problem comes when it tries to compare lets say 5642007779 and 5642007780.... because it changes it into 5.64*10^9 for both cases... it assumes the data is equal.
Are you sure? I get not equal with
x = 5642007779;
y = 5642007780;
isequal(x, y)

Sign in to comment.

 Accepted Answer

5642007779 is not "large". The output "5.642 * 10^9" appears in the command window, but the internal storage is not affected. Try: "format long g" to influence the output in the command window. Further explanations can be found by: doc format

More Answers (1)

Depending on your application you can work with INTEGER data types or work with comparing "between x-phi and x+phi boundaries".

3 Comments

Thanks Andreas... im not much familiar with Matlab much... it would be great if you can just give me a little more details on comparing "between x-phi and x+phi boundaries".
Your profile is empty. I think it depends on what your situation is. Are you a computer science student? then you really should try to understand the underlying fundamentals of this behaviour. Are you are biologist researcher? Then you probably just need a solution without understanding each detail. But then we would a fully example inclusing data and not just a code fragement.
Hello Andreas, sorry that i havent updated my profile yet.. i will update it soon..... but i had a problem with only formatting the output. as mentioned by Jan. Thank you very much for the response.

Sign in to comment.

Tags

Asked:

on 26 Nov 2012

Community Treasure Hunt

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

Start Hunting!