필터 지우기
필터 지우기

Why is my code identifies only few peaks?

조회 수: 1 (최근 30일)
Chaitanya Bade
Chaitanya Bade 2017년 4월 17일
댓글: Greg Dionne 2017년 5월 11일
Hello there,
I have a code that generates graph of two column vectors by plotting the peak values. The code works well except for a case where if i add mean to center my axis,it is plotting only first one or 2 peaks for the files. However, if i take off the the code in brackets which is to find mean ( a1 = XDATA - mean (XDATA); plot(TIMESTEPS, a1); ) the code works well identifying all the peaks. Can anyone help me out with this?
>> %BATCH MODE
files = dir('C:\Users\Deakin Uni\Documents\MATLAB\a\*.xlsx');
fNames = {'90','110','150'};
%for each file
for k= 1: length(fNames)
% extract file names
fName = ['C:\Users\Deakin Uni\Documents\MATLAB\a\', fNames{k}];
[XDATA, TIMESTEPS] = importfile(fName);
a1 = XDATA - mean (XDATA);
plot(TIMESTEPS, a1);
[peakvals,peaklocs] = findpeaks(a1, 'minpeakdistance',50, 'minpeakheight', 0.00001);
peaktime = TIMESTEPS(peaklocs);
createfigure4(TIMESTEPS, a1, peaktime, peakvals)
saveas(gcf,sprintf('chaitu%d.png',k));
end
Looking for a quick answer
Thanks in advance

채택된 답변

Greg Dionne
Greg Dionne 2017년 5월 2일
you probably should also subtract the mean from the value you passed to 'minpeakheight' if you want it to track the data.
  댓글 수: 4
Chaitanya Bade
Chaitanya Bade 2017년 5월 9일
Also, do you know how can i run the csvwrite command in a loop. I have used the one mentioned above. It doesn't work. Any suggestions?
Greg Dionne
Greg Dionne 2017년 5월 11일
Probably best to ask a separate question for that (include what you tried and what's not working well). I've used xlsread and xlswrite but I'm not trying to write streamed output like you are.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by