Code covered by the BSD License  

Highlights from
Polynomial Toolbox: polyBox Version 2.1

image thumbnail

Polynomial Toolbox: polyBox Version 2.1

by

 

06 May 2013 (Updated )

Polanomial approximation, polynomials as admissible functions, a comprehensive tutorial.

Demonstrate 2: Constrained Polynomials and Beam Measurements

Demonstrate 2: Constrained Polynomials and Beam Measurements

This data set represents uncertain measurements of the deflection of a doubly clamped beam. The aim is to fit a curve through the data which fulfille the theoritical known constraints existing at both ends of the beam.

(c) 2013 Paul O'Leary and Matthew Harker

Contents

The constraints on a doubly clamped beam are

$$ y(0) = 0$$
$$ \frac{d y(0)}{d x} = 0 $$
$$ y(1) = 0$$
$$ \frac{d y(1)}{d x} = 0 $$

Prepare MATLAB for The Computation

close all;
clear all;
%
% Set some defaults
%
FontSize = 12;
set(0,'DefaultaxesFontName','Times');
set(0,'DefaultaxesFontSize',FontSize);
set(0,'DefaulttextFontName','Times');
set(0,'DefaulttextFontSize',FontSize);
set(0,'DefaultfigurePaperType','A4');
set(0,'DefaultTextInterpreter', 'latex');
%

Load a Dataset Containing Perturbed Measurements and Constraints

The data points are contained in x and y.

load fitBeamData;
%

Define the Required Constraints

c1 = [0,x(1),0];
c2 = [1,x(1),0];
c3 = [0,x(end),0];
c4 = [1,x(end),0];
%
Cs = [c1; c2; c3; c4];
%

Perform the Constrained Approximation

Call polyfitconstrained to compute the constrained fit.

d = 5;
[pc, Lp, S] = polyfitconstrained( x, y, d, Cs );
%
% Evaluate at a lagre number of points
%
nrPts = 500;
xc = linspace( min(x), max(x), nrPts)';
yc = polyval( pc, xc );
%

Plot the Results of the Approximation

fig1 = figure;
plot(x,y,'ko');
xlabel('x');
ylabel('y');
grid on;
hold on;
plot( xc, yc, 'b', 'LineWidth', 1.5);
title( 'Constrained Polynomial Aproximation' );
%
% Add the positions of the constraints to the plot
%
[n,m] = size(cs);
csText = [];
for k = 1:n
    xk = cs(k,2);
    vk = polyvander( xk, d );
    yk = vk * pc;
    %
    plot( xk, yk, 'ko', 'markerFaceColor', 'r');
end;

Zoom in on one End of the Beam

Zooming in on the end of the beam show that the fit fulfils both the zero value and zero derivative constraints.

figure(fig1);
axis([0.8,1,-0.01,0.01]);
%

Present the Covariance of the Aolution as an Image

This is the covariance matrix of the approximation for the constrained y. Note: the zero covariance at the points where the value constraint is zero.

fig2 = figure;
imagesc( x, x, S.Ly );
axis image;
xlabel('Support');
ylabel('Support');
title('Covariance of the Approximation');
colorbar;
hold on;

Contact us