Find function not working when trying to look for a big number
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Daniel Shub
el 26 de Nov. de 2012
Are you sure? I get not equal with
x = 5642007779;
y = 5642007780;
isequal(x, y)
Respuesta aceptada
Jan
el 26 de Nov. de 2012
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
Más respuestas (1)
Andreas Goser
el 26 de Nov. de 2012
Depending on your application you can work with INTEGER data types or work with comparing "between x-phi and x+phi boundaries".
3 comentarios
Andreas Goser
el 26 de Nov. de 2012
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.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!