Create a Step Sine wave

조회 수: 8 (최근 30일)
Rashmil Dahanayake
Rashmil Dahanayake 2013년 12월 20일
답변: Rashmil Dahanayake 2013년 12월 20일
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;

답변 (3개)

Rashmil Dahanayake
Rashmil Dahanayake 2013년 12월 20일
This Code produce a symmetric quasi square wave. Any ideas to change the number of steps to 6, instead of 3.
To=0.02; %period
t=(0:To/500:To)';
f=sign(sin(2*pi*t/To))/2+sign(sin(-6*pi*t/To))/6;
plot(t,f7);grid on;

Walter Roberson
Walter Roberson 2013년 12월 20일
You did not sample at a high enough resolution. Or, alternately, use a stairs() plot
  댓글 수: 1
Walter Roberson
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)

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


Rashmil Dahanayake
Rashmil Dahanayake 2013년 12월 20일
The stairs() doesn't produce a symmetric wave.
I need a 3 level symmetric wave like http://imgur.com/FPtDiTb
That's why I sampled at Ts/3.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by