how to define a sinusoid function over a specific range

Hi all,
I wonder how to define sin function over a specific range of n. For example, n=1:20 and
x= sin(pi*n) over 0<n<5 and 0 elsewhere.
it should be modified in a way so that I can time shift it or scale it
Thanks

댓글 수: 1

Just calculate it up to 5 and then append 0s to the end.

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

답변 (1개)

Sven
Sven 2018년 8월 30일
편집: Sven 2018년 8월 30일
f = 10; % Frequency in Hertz
a = 2; % Amplitude
startTime = 0; % Time in seconds
endTime = 10; % Time in seconds
samples = 100; % Number of samples
x = linspace(startTime,endTime,samples);
y = a*sin(2*pi*f*x);
plot(x,y)
linspace produces a vector with evenly spaced points between startTime and endTime. If you work with radians, just delete the 2*pi inside the sine function.

댓글 수: 1

Thank you. But what I wanted was a conditional function that is defined over all the values of n, though it is zero for n>5 I intend to use it as an input to a system and modify by time shifting or scaling

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

카테고리

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

질문:

2018년 8월 30일

댓글:

2018년 8월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by