İmporting values form excel to matlab and use them in array

2 ビュー (過去 30 日間)
fatih acar
fatih acar 2013 年 9 月 26 日
編集済み: Yatin 2013 年 10 月 16 日
hi,
I have excel documents which contain time-velocity values in two coloumns so i used xlsread command to import values to matlab for calculating distance but i have a problem
time = xlsread(filename,1,'coloumn1'); velocity = xlsread(filename,1,'coloumn2');
the problem is how can i use this values in a loop form beginnig to end.(I want to use for loop and how can i put this values in array one by one)
  1 件のコメント
dpb
dpb 2013 年 9 月 26 日
doc for
has a couple of examples...
But, in general the idea in Matlab is to not use for...end loops unless mandatory; that "throws away" the power of vectorization that is the raison d'etre for Matlab to begin with.
What are you trying to accomplish--perhaps there's a better way (then again, sometimes a loop is the right answer, too).

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

回答 (1 件)

Yatin
Yatin 2013 年 10 月 16 日
編集済み: Yatin 2013 年 10 月 16 日
Hi,
By using the "xlsread" function you can directly get all the data from the excel sheet into a matrix. You can then directly obtain the individual columns of the matrix. For e.g: The first columns of the matrix (say M) will be M(:,1). You can then get the total number of elements in a column by using the " numel " function and then can iterate from 1 to the number of elements in the vector in a for loop. Hope this helps.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by