Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!postnews.google.com!z27g2000prd.googlegroups.com!not-for-mail
From: vedenev <vedenev.maxim@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to generate this time-domain signal in matlab...
Date: Fri, 6 Feb 2009 02:23:31 -0800 (PST)
Organization: http://groups.google.com
Lines: 22
Message-ID: <34371c10-0214-4c07-9759-c1701bcae767@z27g2000prd.googlegroups.com>
References: <26629693.1233860851876.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: 89.251.107.20
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1233915812 2388 127.0.0.1 (6 Feb 2009 10:23:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 6 Feb 2009 10:23:32 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: z27g2000prd.googlegroups.com; posting-host=89.251.107.20; 
	posting-account=4kIhLQoAAAA5O3xkqw3S1hEVU2lwNKQO
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.6) 
	Gecko/2009011913 Firefox/3.0.6,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:516570


You can use switch with floor:

t=...
switch floor(t)
    case -3   % -3<=t<-2
        x=0;
    case -2   % -2<=t<-1
        x=t+3;
    case -1   % -1<=t<0
        x=1;
    case 0   % 0<=t<1
        x=1;
    case 1   % 1<=t<2
        x=-t+3;
    case 2   % 2<=t<3
        x=0;
end

-----------------------------------------
Maxim Vedenev, MATLAB Custom Programming
vedenev@ngs.ru
http://simulations.narod.ru/