Avoiding load and/or for loop - speed up

11 ビュー (過去 30 日間)
Ann Gerber
Ann Gerber 2020 年 10 月 19 日
コメント済み: Mathieu NOE 2020 年 10 月 20 日
Hi everyone!
I have a directory containing mat-files. they all contain vectors A and B.
I would like to find the maximum value A.*B out of all the mat files. However loading all the .mat files and checking if the maximum value from all the last files is crossed is very timeconsuming:
for i = first:last
load(filename{i})
U = lowpass(A,wpass)*U_scale; % [V] Lowpass-filtered & scaled voltage data
I = lowpass(B,wpass)*I_scale; % [A] Lowpass-filtered & scaled current data
E = abs(U.*I)*t_S;
E_quant = quantile(E,0.9);
if E_max < max(E_quant)
E_max = max(E_quant);
end
end
How do I do this efficiently?
Thanks a lot!
Ann
  8 件のコメント
Ann Gerber
Ann Gerber 2020 年 10 月 19 日
I get the final data and have no influence on how they are generated unfortunately. Thanks anyway! When profiling the script I noticed that filtering is very timeconsuming...
Mathieu NOE
Mathieu NOE 2020 年 10 月 20 日
maybe you could decimate the data inside the loop before doing the low pass filtering
depends what is the original sampling rate and what bandwith must be kept for U and I ( for your computation E = abs(U.*I)*t_S;)
as decimation applies also low pass filtering , you have your lowpass effect plus you reduce the size of U and I.
=> help decimate

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

回答 (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