how to define a sinusoid function over a specific range
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!