How to write code for a composite signal with instantaneous frequency

조회 수: 7 (최근 30일)
Jan Ali
Jan Ali 2020년 11월 20일
댓글: Jan Ali 2021년 1월 10일
Anyone can help me with writing code for this function?

채택된 답변

Swetha Polemoni
Swetha Polemoni 2020년 11월 23일
Hi Jan Ali,
It is my understanding that you want to add three signals that are defined only in particular intervels of time. Following code might help you.
t = (-1:0.01:1); % defining time axis
unitstep1=t>=0; % unitsetp1 takes 1 only when t is greater than equal to 0
unitstep2=t>=0.1; % unitsetp2 takes 1 only when t is greater than equal to 0.1
unitstep3=t>=0.18;% unitsetp3 takes 1 only when t is greater than equal to 0.18
unitstep4=t>=0.3; % unitsetp4 takes 1 only when t is greater than equal to 0.3
rect1=unitstep1-unitstep2; % rect1 takes 1 only when 0<=t<0.1
rect2=unitstep2-unitstep3; % rect2 takes 1 only when 0.1<=t<0.18
rect3=unitstep3-unitstep4; % rect2 takes 1 only when 0.18<=t<0.3
% taking three random sine siganls
Signal1=sin(2*pi*50*t);
Signal2=sin(2*pi*150*t);
Signal3=sin(2*pi*500*t);
% Composite signal
Sc= Signal1*rect1+Signal2*rect2+Signal3*rect3;
  댓글 수: 8
Jan Ali
Jan Ali 2020년 12월 9일
Thanks so much dear Swetha. As you notice, there is a transient in the 0,1 to 0,18 s time interval. I also got the same plat as you did, however not able to get the same as the picture above. Anyway, I really appreciate your effort and the time you spent to get the same result.
Wish you all the bests!
Warm regards,
Ali
Jan Ali
Jan Ali 2021년 1월 10일
Dear Swetha,
I found a workaround for this problem :)
fs=2000;
t = linspace(0,0.3,1000);
s1 = sin(2*pi*30*t) + 0.2*sin(2*pi*70*t);
s2 = sin(2*pi*30*t) + 0.2*sin(2*pi*70*t) + sin(2*pi*500*t).*exp(-30*t-0.1);
s3 = sin(2*pi*30*t) + 0.2*sin(2*pi*70*t);
if 0.1 > t >= 0
s1;
elseif 0.18 > t >= 0.1
s2;
else
s3;
end
s=[s1 s2 s3];
t = linspace(0,0.3,3000);
plot(t, s, 'b')
I really appreciate your kind support and the time you spent for coding.
Wish you all the best

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by