# cutting up the signal into repeating parts

조회 수: 48(최근 30일)
sara bitarafan 2018년 5월 17일
편집: John Kelly 2018년 5월 23일
I was wondering how can I cut up the signal from the data into repeating parts(each containing a single action potential) and then plot all these action potentials on a single graph, at the end shift all these action potentials in time so they are aligned along the x-axis (time ). data is attached
##### 댓글 수: 1표시숨기기 없음
per isakson 2018년 5월 18일
"a single action potential" where does it start and end? Start: The signal is increasing and passes -40 or something of that kind?

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

### 채택된 답변

Star Strider 2018년 5월 18일
편집: Star Strider 2018년 5월 18일
I seem to have seen this waveform somewhere else recently!
Try this:
tv = D(:,1);
ap = D(:,2);
[pks, locs] = findpeaks(ap, 'MinPeakHeight',100, 'MinPeakDist',20); % Determine Peaks & Indices
figure(1)
plot(tv, ap)
hold on
plot(tv(locs), pks, '+r')
hold off
grid
for k1 = 1:numel(locs)-1
apc{k1} = ap(locs(k1)-10:locs(k1+1)-10); % Define MUAP Frames
tvc{k1} = tv(locs(k1)-10:locs(k1+1)-10);
end
figure(2)
hold all
for k1 = 1:numel(apc)
plot(tvc{k1}-tvc{k1}(1), apc{k1}) % Plot MUAP Frames
end
hold off
grid
That should get you started.
Experiment to get the result you want. Jan 2018년 5월 23일

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

### 추가 답변(1개)

John BG 2018년 5월 18일
편집: John BG 2018년 5월 18일
Hi Sara Bitarafan
please have a look at the attached script. .
1.-
Acquiring signal:
clear all;clc;close all
t=A(:,1)'
s=A(:,2)'
figure(1)
plot(t,s);grid on
Removing DC
min_s=min(s)
s=s+abs(min_s)
center signal, closest to dominant cycle to a sin cos signal
max_s=max(s)
s=s-max_s/2
hold on
plot(t,s);grid on;axis tight For this sample there's not much DC, but it may the case that without removing DC the sought eye diagram is difficult to get.
2.
Calculating the dominant cycle with fft:
.
S=fft(s)
absS=abs(S);
figure(2);
plot(absS);grid on;
max_absS=max(absS);
n_maxS=find(absS==max_absS)
.
2nd value is just FFT mirror
n_maxS=n_maxS(1)
.
If n_maxS = max_amount_cycles this would be the highest discernible requency, with the FFT: it would be just 2 time samples per cycle.
max_amount_cycles=floor(numel(t)/2)
.
n_maxS: amount of cycles
.
hold on;plot(n_maxS,max_absS,'ro') .
nT: amount of samples per dominant cycle:
nT=floor(numel(t)/n_maxS)
.
dominant cycle T
t1=t([1:nT])
T=t1(end)
amount of lost samples ignoring .2
mod(nT,n_maxS) % samples lost, not a crisis
.
% sc=zeros(n_maxS,T)
% for ,,
s2=s([1:1:end-(numel(t)-n_maxS*nT)])
.
But the dominant cycle is not that constant.
figure(3);
for k=1:1:3 % n_maxS
plot(s2(k*[1:nT]))
hold on;
end
% 003 .
For the same basic cycle t(nT) we see 1,2 and 3 peaks
This is caused by a 2nd tone almost half way the dominant tone in amplitude and really close to the dominant.
fft approach is more reliable when there's a clear frequency peak but no high tones anywhere, particular near the dominant.
Yet the variable nT is going to be useful in next point.
Also, assuming the single action potential refers to a single peak
3.-
When the dominant cycle is not that constant we can use squelch:
Set a threshold that includes all peaks above a given amplitude.
close all
s=A(:,2)'
th1=100
figure(1);plot(t,s);grid on
[pks,locs]=findpeaks(s,'MinPeakHeight',th1)
hold on
plot(t(locs),pks,'bd')
avoid false peaks imposing min distance between found peaks, that may be for instance: nT
.
[pks,locs]=findpeaks(s,'MinPeakHeight',th1,'MinPeakDistance',floor(nT/2))
hold on
plot(t(locs),pks,'rd')
% 004 .
So far what can we assert about this signal and the 'potential' events you have mentioned in the question?
How often do the events take place
mean(diff(locs))
.
How much jitter suffer such events understanding jitter ~ standard deviation of locs
var(diff(locs))^.5
4.-
Plotting the centered diagram with all events:
Let be dt the + - span left and right of each peak event
dt=floor(.5*mean(diff(locs)))
And the eye diagram:
sc2=zeros(numel(locs),2*dt+1) % + - window span around each peak
for k=1:1:numel(locs)
if locs(k)<dt % 1st cycle, with 1st peak closer than dt to beginning of signal.
s0=s([1:locs(k)+dt])
sc2(k,:)=[zeros(1,2*dt+1-numel(s0)) s0]
end
if locs(k)>numel(t)-dt % last cycle with peak closer than dt to end of signal.
sc2(k,:)=s([locs(k)-dt:end])
end
if locs(k)<numel(t)-dt && locs(k)>dt
sc2(k,:)=s([locs(k)-dt:locs(k)+dt])
end
end
% 4. and the eye diagram is:
figure(2);
for k=1:1:numel(locs)
plot(sc2(k,:))
hold on
end
grid on
% 005
. .
Sara
thanks in advance for time and attention
John BG
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
John BG 2018년 5월 21일
Thanks Sara

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

### Community Treasure Hunt

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

Start Hunting!