Saturday, November 21, 2009

Cubic spline data analysis.

%this program is useful to learn matlab.
%nwe nwe htay learning matlab 11 no.2009
%5:53:34 AM

%load('K:\matlab.mat')
%Example 5. The following code generates sine and cosine curves,
%then samples the splines over a finer mesh.

x = 0:.25:1;
Y = [sin(x); cos(x)];
xx = 0:.1:1;
YY = spline(x,Y,xx);
plot(x,Y(1,:),'o',xx,YY(1,:),'-'); hold on;
plot(x,Y(2,:),'oY
0 0.2474 0.4794 0.6816 0.8415
1.0000 0.9689 0.8776 0.7317 0.5403
Y(1,:) %GENERATING 1 st. row.

%ans =
0 0.2474 0.4794 0.6816 0.8415
Y(:,5) %generting 5 th. column.
%ans =
% 0.8415
% 0.5403
Y %generating matrix y
%Y =
% 0 0.2474 0.4794 0.6816 0.8415
% 1.0000 0.9689 0.8776 0.7317 0.5403
Y(2,5) %element(2,5)
%ans =
% 0.5403
%Y(2,3)
%ans =
% 0.8776

No comments: