フィルターのクリア

how I can minimize time of running of a code

1 回表示 (過去 30 日間)
Amr Hashem
Amr Hashem 2015 年 5 月 21 日
コメント済み: Adam 2015 年 5 月 21 日
I use a code to categorize data (by searching in text for words) this is the data(it consists of 40000 row):
i use this code:
tic
j=1;
k=1;
D=alldata(:,54);
E=class(D{5});
for H = 1:R % for loop to remove NaN
if isnan(D{H})
D{H} = '';
end
end
%
for E=1:2 % from 1 : length of columns
B=~cellfun('isempty',regexp(D,'deliver')) ; % search for battrey and return 1 or 0
if (B(E) == 1) % if value of array greater than or equal 1
Defs(j)=E; % save its postion (E,1)
j=j+1;
else % save all arrays didn't have 'check' separately
not(k)=E;
k=k+1;
end
end
data=alldata(Defs,:); % show data contains 'battery'
notdata=alldata(not,:); % show data didn't contain
toc
xlswrite('result2000.xlsx',data,10); % save result in sheet 4
xlswrite('result2000.xlsx',notdata,11);
but it takes very big time
2911 sec about 48 minute
and I need to run the code many times (searching for several words in 5 different columns)
how i could modify the code to run in less time ?
  1 件のコメント
Adam
Adam 2015 年 5 月 21 日
profile on
...your code...
profile off
profile viewer
is the best way to find the slow parts of your code to focus on for speeding up. tic toc is only really useful for getting an overview of a given section of code.

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by