0

My question is hopefully a simple one for experienced Matlab users. How can I import data in an Excel sheet to Matlab without Matlab automatically converting the numeric data to scientific notation?

The data I'm working with are ID numbers, up to 12 digits long, so I need to see (for example)

30094111063

and not

3.0094e+10

or else Matlab confuses similar ID numbers, for example 30094111063 and 30094111742, later in the code as a "match", because they both appear as 3.0094e+10.

Things I've tried so far without success: xlsread, uiopen, sscanf. I've also seen answers to very similar questions to mine on StackOverflow, but for Access, R, Python, etc. and not Matlab, so hopefully this is useful to future users.

Thanks!

Edit: Here's an example of the code I'm working with:

A = xlsread('test1974.xlsx');
B = xlsread('test1975.xlsx'); 

adj = zeros(N,N);  
for i=1:N;  
    for j=1:N;  
        if A(i,:) == B(:,j)  
            adj(i,j) = 1;  
        else adj(i,j) = 0;  
        end;  
    end;  
end; 

The code is creating "false positive" matches between A and B.

DanMcK
  • 37
  • 9
  • I was about to post something about [format long](http://www.mathworks.com/help/matlab/ref/format.html), until I read the part about `Matlab confuses similar ID numbers...as a "match"`. So Matlab is actually seeing these two as the same number? Or do they just look the same in the output. Could you show us some code? – beaker Jul 23 '14 at 17:51
  • Sure, thanks. Right now I'm reading in my Excel file as follows, creating the matrix A: A = xlsread('test1974.xlsx'); The problem arises when I run this matrix through a "for-end" loop that looks for matches between A and a similar data set, B, where the relevant portion of the code is if A(i,:) == B(:,j) It's creating "false positive" matches between ID numbers. – DanMcK Jul 23 '14 at 17:53
  • 1
    Please add your code by editing the question. It's much harder to read in a comment. Please also show the erroneous results you're getting. – beaker Jul 23 '14 at 17:59

1 Answers1

1

add this code to your script:

format long

Example:

>> 33333333333333

ans =

   3.3333e+13

>> format long
>> 33333333333333

ans =

     3.333333333333300e+13
lakshmen
  • 28,346
  • 66
  • 178
  • 276