我有一个像上面那样的信号。如何使用matlab计算有多少部件?我们可以很容易地计算出我们的眼睛有5个部分,但是在matlab中?如何估算每个信号衰减的频率?
答案 0 :(得分:0)
这是一个可以根据您的情况修改的解决方案。
%% Generating signal
x= 1:0.1:100;
xx= zeros(1,50);
xx= [x,xx];
x= [7*xx, 1.4*xx , 3*x, 4*xx, 6*x];
y= sin(x*50).*exp(-0.02*x); %The signal i use
figure(1)
plot(y)
y2=diff(y); %The diveration of the signal (y(i)-y(i-1))
figure(2)
plot(y2)
%% Parameter to modify solution
epsilon = 0.005; %interval of acceptance (derivation under epsilon)
train_of_zeros = 8; %how many zeros have to be between to signals to differentiate them
%% computation
y2(abs(y2)<=epsilon)=0; %setting all points with amplitude less or equal of epsilon to nil
z=find(y2); %finding the indices of the nonzero values.
No_Of_Signals=0; %Number of Signals
end_begin_Signal = [NaN, 0]; %help variable for saving the begin and end of signal
for k=2:1:numel(z)-1 %for all elements of z check:
if abs(z(k+1))>=abs(z(k)+train_of_zeros) %if there are at least train of zeros between 2 non zero elements
end_begin_Signal = [end_begin_Signal; z(k) z(k+1)]; %saving those indices
No_Of_Signals=No_Of_Signals+1; %plus one signal
end
end
The_Signals = cell(No_Of_Signals+1,2); %save variable for begin and end of a signal
The_Signals(1,:)= {'Begin of Signal', 'End of Signal'};
for l=2:1:No_Of_Signals+1
The_Signals(l,:) = {end_begin_Signal(l-1,2), end_begin_Signal(l,1)};
end