Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Triangular Waveform in Matlab

60 views
Skip to first unread message

Waldir

unread,
Feb 6, 2002, 3:07:58 PM2/6/02
to
Hello,

I'd like to create a periodic triangular waveform (0-1) with period = T.
How can I do that in Matlab?

Thanx a lot.

Waldir

Scott Seidman

unread,
Feb 6, 2002, 4:45:07 PM2/6/02
to
wal...@eletrica.ufjf.br (Waldir) wrote in
news:17c67203.02020...@posting.google.com:

Off the top of my head, I would use the integral (or cumulative sum) of a
square wave that's center around zero.


Scott

Alistair W Smith

unread,
Feb 6, 2002, 4:51:24 PM2/6/02
to

Can't you use mod(x/T,1) or something?

Andreas Keese

unread,
Feb 7, 2002, 11:36:50 AM2/7/02
to
Waldir wrote:
>
> Hello,
>
> I'd like to create a periodic triangular waveform (0-1) with period = T.
> How can I do that in Matlab?

Try this:
T=20;
x=linspace(0,5*T,1000);
y1=min(0.5,mod(x,T)/T);
y2=min(0.5,1-mod(x,T)/T);
plot(x,y1+y2)

Andreas

Don Orofino

unread,
Feb 7, 2002, 2:53:31 PM2/7/02
to
If you have access to Signal Processing Toolbox:

TRIPULS Sampled aperiodic triangle generator.
TRIPULS(T) generates samples of a continuous, aperiodic,
unity-height triangle at the points specified in array T, centered
about T=0. By default, the triangle is symmetric and has width 1.

TRIPULS(T,W) generates a triangle of width W.

TRIPULS(T,W,S) allows the triangle skew S to be adjusted. The
skew parameter must be in the range -1 < S < +1, where 0 generates
a symmetric triangle.

See also SQUARE, SIN, COS, CHIRP, DIRIC, GAUSPULS, PULSTRAN and
RECTPULS.

Carl Porter

unread,
Feb 14, 2002, 1:14:47 AM2/14/02
to
I'm trying something similar, I need a triangular waveform with adjustable
time span (ts) & frequency (f). This is supposed to give me an amplitude of
1. I can't get it to work. The error message I get says the matrix dimension
must agree on m*sgn*t. OK 'm' is a scalar , sgn and t are 1001 elements so
what's the problem? Then I need to work out the offset part, 'n', to get the
proper number of elements

ts=2E-3;
f=1000;
t=[0:ts/1000:ts];
sgn=sign (sin(2*3.14159*f*t));
m=2*f;
n=[0:1/f:ts];
y=(m*sgn*t)+(n*1/f);
plot (t,y)

Julio

unread,
May 11, 2012, 4:40:25 AM5/11/12
to
wal...@eletrica.ufjf.br (Waldir) wrote in message <17c67203.02020...@posting.google.com>...
try :

triSignal = (sawtooth(2.*pi.*1/T.*time,dutyCycle)+1)/2 %Sawtooth or triangle wave

sandeep mishra

unread,
Jan 24, 2014, 2:07:08 PM1/24/14
to
mishra...@yahoo.in (sandeep) wrote in message <17c67203.02020...@posting.google.com>...
> sandeep
0 new messages