%**************************************************************************
%This function plots the trajectory.
%The filtered trajectories are also plotted.
%
%Input:
%plt_file, plot file for results
%param, structure containing analysis parameters
%traj_name, 'X' or 'Y'
%z, position along the undulator (m)
%x, x or y trajectory position (m)
%x_filt, x or y filtered trajectory position (m)
%
%Zachary Wolf, 1/8/06

function [] = traj_plot_traj(plt_file, param, traj_name, z, x, x_filt)

%Plot the trajectory
if param.fig_vis == false
    figure('visible', 'off');
else
    figure('visible', 'on');
end
hold on;
x_max = max(x);
x_min = min(x);
if (x_max < 2.e-6) && (x_min > -2.e-6)
    ylim([-2.e-6, 2.e-6]);
end
plot(z, x, 'linewidth', 0.5);
title([traj_name, ' Trajectory']);
ylabel([traj_name, ' (m)']);
xlabel('Z position (m)');
grid on;
zoom on;

%Plot the lambda filtered trajectory
plot(z, x_filt, 'linewidth', 3.);
util_add_pole_num_to_plot(param);  %Add pole numbers to the plot
hold off;

%Write the figures to the plot file
util_print_fig(plt_file);

%Done
