DanMcK
DanMcK

Reputation: 37

Import Excel to Matlab without numeric data appearing in scientific notation

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.

Upvotes: 0

Views: 1172

Answers (1)

lakshmen
lakshmen

Reputation: 29064

add this code to your script:

format long

Example:

>> 33333333333333

ans =

   3.3333e+13

>> format long
>> 33333333333333

ans =

     3.333333333333300e+13

Upvotes: 1

Related Questions