how to read excel data

Hello everyone,
I want to create a function which will read data from a given excel file and will return different vectors, each corresponding to a different vector (numerical data only). Do you have any idea?
thank you

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 30 日

0 投票

To get numerical data
v=xlsread('your_file.xlsx')

5 件のコメント

jimaras
jimaras 2014 年 1 月 30 日
this works when I compile in command window, but I want to create a function (which reads this data and will separate the columns into different vectors), so I am doing this:
filename='excelfile.xlsx'; Function(filename)
and I get the following message
Undefined function 'ReadApple' for input arguments of type 'char'.
What am I doing wrong?
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 30 日
Post your function
jimaras
jimaras 2014 年 1 月 30 日
編集済み: Azzi Abdelmalek 2014 年 1 月 30 日
%Function Trasformation which reads part of data from excel file
%and returns this data in form of vectors;
function[K]= Trasformation(filename)
K=xlsread(filename);
n=length(K);
K
jimaras
jimaras 2014 年 1 月 30 日
編集済み: Azzi Abdelmalek 2014 年 1 月 30 日
and in the command window I set
filename='excelfile.xlsx';
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 30 日
This doesn't make any sens, you are just replacing the function xlsread by Transformation. Just write
K=xlsread('yourfile.xls')
Then do whatever you want with the matrix K. And it's a bad idea to separate it to many vectors. If you want a third column, you can get it by
K(:,3)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

質問済み:

2014 年 1 月 30 日

コメント済み:

2014 年 1 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by