Shifting a Square Wave in Matlab

7 ビュー (過去 30 日間)
Big Meech
Big Meech 2013 年 9 月 24 日
Hello,
I'm having trouble creating a square wave. I have created my square wave using the gensig function but now my goal is to shift the wave over 0.5 units to the left so that it reads 1 from 0 to 0.5.
Can anyone offer any solutions to this or give me advice?
Do I now have to use a different function?
Code:
[u,t]=gensig('square',0.5,5,0.001)
plot (t,u); axis([0 5 -2 2])

採用された回答

Walter Roberson
Walter Roberson 2013 年 9 月 24 日
plot(t-0.5, u)

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 24 日
[u,t]=gensig('square',1,5+0.5,0.001)
u=u(t>0.5)
t=t(t<t(end)-0.5)
close
plot(t,u,'r')

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by