Importing data from Excel to Matlab problem

조회 수: 2 (최근 30일)
Simon
Simon 2013년 7월 2일
답변: Bheki SIFUBA 2019년 10월 19일
Hi guys, I'm having a problem important datas from Excel. I used to import ranges because I found it easier, but now I need to gather a whole sheet from Excel. When I use xlsread, The import is working but the first row of my sheet, which contains the name of my variables disappears. I would like to keep em after important. Thank you in advance.

답변 (3개)

Evan
Evan 2013년 7월 2일
편집: Evan 2013년 7월 2일
This has to do with the output arguments when you call xlsread. With only one output argument, only numerical data is read in into separate arrays. With two arguments, numerical and text is read in. If you want to pull the data in all as a single cell array with different datatypes, specify a third output argument, like so:
[num,txt,raw] = xlsread(___);
And if you don't want the separate numerical and text arrays:
[~,~,raw] = xlsread(___);

Simon
Simon 2013년 7월 2일
OK it seems to work, but the result is not really what I expected. When I do :
%
Exemple = xlsread('filename','Database','CD5:CD530');
X1 = dataset(Exemple);
The first cell of the name is now my Variable name. I wanted to have a way to do the same exact thing but with an entire sheet, getting every column and that the first row of every columns become the column's title.
  댓글 수: 1
Evan
Evan 2013년 7월 3일
편집: Evan 2013년 7월 3일
If the example code you posted is the one you're using, it doesn't look like you're getting raw output. You need to specify your call to xlsread like this:
[~, ~, Example] = xlsread('filename','Database','CD5:CD530');
That should read your excel data into a cell matrix that is essentially a cell-for-cell copy of your excel spreadsheet, no matter the format or datatypes of your different columns.
Apologies if I'm misunderstanding your problem.

댓글을 달려면 로그인하십시오.


Bheki SIFUBA
Bheki SIFUBA 2019년 10월 19일
I have 3 different data types in one cell (column), one is text and the other two are numbers, how can I import in 3 different rows?

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by