how to import data in excel format to Matlab

Asked

Viewed 12,986 times

2

I want to import data from excel to Matlab, I’ve tried with importdata but there is some thing that doesn’t add up. I see «Nan» instead of numbers in the matrix

  • which code you tried?

2 answers

5

Have you tried using xlsread?

xlsread(nome do arquivo,pasta,intervalo)

Example:

% Criar um arquivo do excel chamado Exemplo.xlsx.

values = {1, 2, 3 ; 4, 5, 'x' ; 7, 8, 9};
headers = {'primeiro','segundo','terceiro'};
xlswrite('Exemplo.xlsx',[headers; values]);

% Pasta tem então os dados (Exemplo.xlsx):

   primeiro    Segundo    Terceiro
       1         2        3
       4         5        x    
       7         8        9

%Ler os dados numéricos da primeira pasta do arquivo:

filename = 'Exemplo.xlsx';
A = xlsread(filename)
A =
     1     2     3
     4     5   NaN
     7     8     9

For more information visit link

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.