Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 197973

Submitted on 29 Jan 2013 by Alfonso Nieto-Castanon

Correct

36Size
Leading solution size is 24.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%% Check linear interpolation
X = [4800; 5100];
Y = [7.5247; 7.2851]*1e-1;
x = 5000;
y = Poly_Interp(X,Y,x)
y_correct = 0.73650;
assert(abs(y-y_correct)<1e-4)
y =
    0.7365
2
Pass
 
%% Check Vandermonde coefficient matrix condition number
X = [4800; 5100];
Y = [7.5247; 7.2851];
x = 5000;
y_correct = 7.3650;
c_correct = 1.6350e+05;
[y,c] = Poly_Interp(X,Y,x)
assert(abs(y-y_correct)<1e-4)
assert(norm(c-c_correct)<1e2)
y =
    7.3650
c =
   1.6350e+05
3
Pass
 
%% Check quadratic interpolation
X = [300, 400, 500];
Y = [0.616, 0.525, 0.457];
x = 350;
[y,c] = Poly_Interp(X,Y,x)
y_correct = 0.567625;
c_correct = [5.8932e+06];
assert(abs(y-y_correct)<1e-4)
assert(norm(c-c_correct)<1e2)
y =
    0.5676
c =
   5.8932e+06
4
Pass
 
%% Check quadratic interpolation for log
X = [1, 4 6];
Y = log(X);
x = 2;
[y,c] = Poly_Interp(X,Y,x)
y_correct = 0.5658;
c_correct = 93.9107;
assert(abs(y-y_correct)<1e-4)
assert(norm(c-c_correct)<1e-2)
y =
    0.5658
c =
   93.9107