Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Implementing splines in a microcontroller
Date: Sun, 22 Nov 2009 17:54:03 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 17
Message-ID: <hebtrr$l6p$1@fred.mathworks.com>
References: <he1kh0$26s$1@fred.mathworks.com> <he1o3c$mqq$1@fred.mathworks.com> <hebpdb$j29$1@fred.mathworks.com> <hebpmo$78c$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1258912443 21721 172.30.248.37 (22 Nov 2009 17:54:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 22 Nov 2009 17:54:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:587044


x = 0:10;
y = sin(x);
s = spline(x,y);

plot(x,y,'o');
hold on

for aspline = 1:length(s.breaks) - 1
    left = s.breaks(aspline);
    right = s.breaks(aspline+1);
    xx = linspace(left,right,17);
    scoefs = s.coefs(aspline,:);
    yy = polyval(scoefs,xx - left);
    plot(xx, yy);
end

% Bruno