function test_models(modelx, modely, coef_x, coef_y)

load observations

R = 30 ;
t = linspace(0, 1, 360) ;
x = R * cos(2 * pi * t)  ;
y = R * sin(2 * pi * t) ;

[x_s, y_s, z_s] = sphere ;
x_s = 5 * x_s ;
y_s = 5 * y_s ;
z_s = 5 * z_s ;
[x_e, y_e, z_e] = sphere ;

tt = 1 : numel(x) ;
if strcmp(modelx, 'f1')
    x_est = coef_x(1) + coef_x(2) * tt + coef_x(3) * tt .^ 2 ;
elseif strcmp(modelx, 'f2')
    x_est = coef_x(1) + coef_x(2) * tt + coef_x(3) * tt .^ 2 + coef_x(4) * tt .^ 3 ;
elseif strcmp(modelx, 'f3')
    x_est = coef_x(1) + coef_x(2) * sin(2*pi*tt/360) + coef_x(3) * cos(2*pi*tt /360) ;
end

if strcmp(modely, 'f1')
    y_est = coef_y(1) + coef_y(2) * tt + coef_y(3) * tt .^ 2 ;
elseif strcmp(modely, 'f2')
    y_est = coef_y(1) + coef_y(2) * tt + coef_y(3) * tt .^ 2 + coef_y(4) * tt .^ 3 ;
elseif strcmp(modely, 'f3')
    y_est = coef_y(1) + coef_y(2) * sin(2*pi*tt/360) + coef_y(3) * cos(2*pi*tt /360) ;
end

figure
subplot(2, 2, 3)
plot(t_obs, x_obs, 'r*')
hold on
plot(tt, x_est, 'g-') ;
plot(tt, x, 'b-')
legend({'Observations', 'Estimated values', 'True values'}) ;
title(['LS fitting on x-observations using the ' modelx ' model']) ;
grid on
subplot(2, 2, 4)
plot(t_obs, y_obs, 'r*')
hold on
tt = 1 : numel(y_est) ;
plot(tt, y_est, 'g-') ;
plot(tt, y, 'b-')
grid on
legend({'Observations', 'Estimated values', 'True values'}) ;
title(['LS fitting on y-observations using the ' modely ' model']) ;

h = subplot(2, 2, [1, 2]) ;
hold on
for i = 1 : numel(t)
    cla(h)
    plot3(x_obs, y_obs, zeros(numel(x_obs), 1), 'r*', 'MarkerSize', 12) ;
    hold on
    surf(x_s, y_s, z_s, 'LineStyle', 'none')  % sphere centered at (3,-2,0)
    colormap('hot')
    freezeColors
    hold on
    surf(x_e + x(i), y(i) + y_e, z_e, 'LineStyle', 'none')  % sphere centered at (3,-2,0)
    colormap('winter')
    plot3(x(1 : i), y(1 : i), zeros(i, 1), 'b-.') ;
    plot3(x_est(1 : i), y_est(1 : i), zeros(i, 1), 'g-', 'Marker', '+', 'MarkerSize', 12) ;
    axis([-R, R, -R, R, -5, 5]) ;
    view([90, 90, 60])
    set(gca, 'DataAspectRatio', [1, 1, 1]) ;
    grid on
%     legend({'Observations', 'Estimated orbit', 'True orbit;'}) ;
    title('Pandora orbitting around its sun') ;
    pause(0.003) ;
%     daspect([20 20 20])
end
