Dear experts could you help me to optimize the code please? My files represent a long series of data points in many columns and it takes ages to calculate the parameters I need by the for loop. My computer is not so powerful too. I tried parfor, it did not help much. Thank you. Oleg
filename= 'data.xlsx';
signal=xlsread(filename,'b:t');
Time=xlsread(filename,'a:a');
detrend_data = detrend(signal, 'linear');
nSig = size(detrend_data);
N = 0;
NPEAKS = zeros([nSig,1]);
NINT = zeros([nSig,1]);
for jj = 1:nSig(2)
[pks, locs, width, p] = findpeaks(detrend_data(:,jj),Time,'MinPeakProminence',0.1,'MinPeakHeight',0.2,'MinPeakDistance',0.5,'Annotate','extents','WidthReference','halfprom');
peakInterval = diff(locs);
lp = length(p);
li = length(peakInterval);
N = max(N,lp);
Ni=max(N,li);
NPEAKS(1:lp,jj) = cat(2,pks);
NLOCS(1:lp,jj) = cat(2,locs);
NWIDTH(1:lp,jj) = cat(2,width);
NPROM(1:lp,jj) = cat(2,p);
NINT(1:li,jj) = cat(3,peakInterval);
end
NPEAKS = NPEAKS(1:N,:);
NLOCS = NLOCS(1:N,:);
NWIDTH = NWIDTH(1:N,:);
NPROM =NPROM(1:N,:);
NINT=NINT(1:Ni,:);
sheet=1;
sheet2=2;
sheet3=3;
sheet4=4;
sheet5=5;
filename2= 'peaks_data';
xlswrite(filename2,NPEAKS,sheet);
xlswrite(filename2,NLOCS,sheet2);
xlswrite(filename2,NWIDTH,sheet3);
xlswrite(filename2,NPROM,sheet4);
xlswrite(filename2,NINT,sheet5);

댓글 수: 2

Rik
Rik 2018년 8월 8일
Without the data itself we can't do very much.
Oleg Tolstenkov
Oleg Tolstenkov 2018년 8월 8일
Thank you. Here comes the example of my data.
Best regards,
Oleg

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기

질문:

2018년 8월 8일

편집:

2018년 8월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by