原帖由 witty01 于 2007-12-4 15:00 发表
恩,是可以的,
但是我想写一段生成周期性三角波的m文件,编是能编的出来啦,我想知道有没有 命令可以直接用的? 谢谢
- 摘要:这个程序可以生成确定长度确定周期的三角波
- 并且上升沿和下降沿的比例是可调节的.
- function [ts,y]=trianglem(t,p,s);
- % triangle wave generation for special shape.
- % t is the range of time and has the size 1x2
- % p is the period of triangle wave
- % "s" is the skale between the rising-edge and
- % the failling-edge. "s" must have values in [0,1]
- % Example:
- % [ts,y]=triangle([0,20],2);plot(ts,y)
- % \copyright: zjliu
- % Author's email: zjliu2001@163.com
- ts=t(1):p/20:t(2);
- y=zeros(size(t));
- yt=mod(ts,p);
- y(yt<=p*s)=yt(yt<=p*s)/p/s;
- y(yt>p*s)=1-(yt(yt>p*s)-p*s)/(p-p*s);
复制代码 |