フィルターのクリア

vectorization for nested loop where inner loop is variable depending on value of element in outer loop

1 回表示 (過去 30 日間)
Hello,
I just learned about vectorization after trying to find a faster way to loop through all the sheets of all the files I need.
Here is basically what I'm trying to do:
for k = 1:arrayOfAllMyFilePaths
%get filepath at k
%get number of sheets in file using filepath
for m = 1:lengthOfNumberOfSheetsInFile
%read some data in each sheet
  7 件のコメント
OCDER
OCDER 2018 年 8 月 2 日
編集済み: OCDER 2018 年 8 月 2 日
Is there a requirement to vectorize this? Not everything should be vectorized or can be vectorized. Mathworks did improve their for loop speeds, and the bottleneck is probably hard drive read speed, as opposed to CPU for calculations (which is what vectorization takes advantage of). For reading files, for loop is good.
"MATLAB® is optimized for operations involving matrices and vectors. The process of revising loop-based, scalar-oriented code to use MATLAB matrix and vector operations is called vectorization."
Stephanie M
Stephanie M 2018 年 8 月 2 日
Good point, I think I'll stick with the for loop and use Active X to speed things up.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by