%**************************************************************************
%This function plots Bz vs x along a line whose y position and z position
%are specified.  The closest x and y positions with data points are used.
%
%Input:
%plt_file, plot file for results
%block, structure containing the block information
%charge, structure containing the magnetic charge information
%mag_field, structure containing the magnetic field information
%y_val_req, requested y position of line to plot Bz along (m)
%z_val_req, requested z position of line to plot Bz along (m)
%
%Zachary Wolf, 3/31/08

function pm_plot_bz_vs_x_at_yz(plt_file, block, charge, mag_field, y_val_req, z_val_req)

%Initialize
figure;
hold on;

%Mark the blocks
for ii = 1 : block.num_block
    plot(block.x_center(ii) - block.x_width(ii) / 2, 0, 'r+');
    plot(block.x_center(ii) + block.x_width(ii) / 2, 0, 'r+');
end

%Plot the field
[y_close, iy_close] = min(abs(mag_field.y - y_val_req));
y_val = mag_field.y(iy_close(1));
[z_close, iz_close] = min(abs(mag_field.z - z_val_req));
z_val = mag_field.z(iz_close(1));
index_array = find((mag_field.y == y_val) & (mag_field.z == z_val) == 1);
plot(mag_field.x(index_array), mag_field.bz(index_array));

%Labels
title(['Bz vs X On Line At Y = ', num2str(y_val), ' m, Z = ', num2str(z_val), ' m']);
xlabel('X (m)');
ylabel('Bz (T)');

%Finalize
grid on;
zoom on;
hold off;

%Print
orient landscape;
print('-append', '-dpsc', plt_file);

%Done
