Create a Step Sine wave
32 次查看(过去 30 天)
显示 更早的评论
Hi, I intend to create a square shaped step sine wave. At the moment I approach this problem by defining a sample time. However it created a triangular wave instead.
Please suggest to correct this. I have optional DSP tool box if necessary.
t=0:1/3:1;
y=sin(2*pi*t);
plot(t,y);grid on;
0 个评论
回答(3 个)
Walter Roberson
2013-12-20
You did not sample at a high enough resolution. Or, alternately, use a stairs() plot
1 个评论
Walter Roberson
2013-12-20
Your 3-level symmetric wave image starts off negative at t = 0. That requires using cos(t) or some other phase offset.
Your 3-level symmetric wave image has a different width for the central part where y = 0, only half the width of the y = -1 and y = +1. Therefore the number of sampling intervals must be increased.
With a small bit of experimentation what I find works acceptably well is
t = linspace(0,1,7);
y = sin(2*pi*(t-1/3));
stairs(t,y)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!