I have a piecewise function where the upper and lower limits of the functions are set to 0.5 and -0.5 for the amplitude of the function cos(pi*t). I am not sure how to code the portion where the amplitude needs to remain at 0.5 for all y values above 0.5 and same for all values to fall below -0.5. I know that cos(pi * t) is a sinusoid with an amplitude from 1 to -1, I need to clip the signal so that the upper clipped values remain at 0.5 and -0.5 for the lower values that get clipped. Any help would be appreciated! My signals class has also introduced me to MATLAB which I have never used before and they have thrown me in the deepend of the pool and I am struggling to tread water. I haven't been able to find any videos on YouTube that help so far, I will continue to look.

답변 (1개)

Dyuman Joshi
Dyuman Joshi 2022년 5월 28일

1 개 추천

t = 0:0.001:10;
y = cos(pi*t);
y(y>0.5)=0.5;
y(y<-0.5)=-0.5;
plot(t,y)
ylim([-1 1])

댓글 수: 3

Anthony Walden
Anthony Walden 2022년 5월 28일
Thank you for the help! That did the trick!
Dyuman Joshi
Dyuman Joshi 2022년 5월 28일
Please accept the answer if it solved your issue.
Another approach -
t = 0:0.001:10;
y = cos(pi*t);
y = max(min(y, 0.5), -0.5);
plot(t,y)
ylim([-1 1])

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

카테고리

도움말 센터File Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

질문:

2022년 5월 28일

댓글:

2024년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by