function output ( u, ibc, indx, nsub, nu, ul, ur, xn ) %% OUTPUT prints out the computed solution at the nodes. % % Modified: % % 01 November 2006 % % Parameters: % % Input, real U(NU), the solution of the linear equations. % % Input, integer IBC. % IBC declares what the boundary conditions are. % 1, at the left endpoint, U has the value UL, % at the right endpoint, U' has the value UR. % 2, at the left endpoint, U' has the value UL, % at the right endpoint, U has the value UR. % 3, at the left endpoint, U has the value UL, % and at the right endpoint, U has the value UR. % 4, at the left endpoint, U' has the value UL, % at the right endpoint U' has the value UR. % % Input, integer INDX(1:N+1). % For a node I, INDX(I) is the index of the unknown % associated with node I. % If INDX(I) is equal to -1, then no unknown is associated % with the node, because a boundary condition fixing the % value of U has been applied at the node instead. % Unknowns are numbered beginning with 1. % If IBC is 2 or 4, then there is an unknown value of U % at node 0, which will be unknown number 1. Otherwise, % unknown number 1 will be associated with node 1. % If IBC is 1 or 4, then there is an unknown value of U % at node N, which will be unknown N or N+1, % depending on whether there was an unknown at node 0. % % integer NSUB. % The number of subintervals into which the interval % [XL,XR] is broken. % % Input, integer NU. % NU is the number of unknowns in the linear system. % Depending on the value of IBC, there will be N-1, % N, or N+1 unknown values, which are the coefficients % of basis functions. % % Input, real UL. % If IBC is 1 or 3, UL is the value that U is required % to have at X = XL. % If IBC is 2 or 4, UL is the value that U' is required % to have at X = XL. % % Input, real UR. % If IBC is 2 or 3, UR is the value that U is required % to have at X = XR. % If IBC is 1 or 4, UR is the value that U' is required % to have at X = XR. % % Input, real XN(1:N+1). % XN(I) is the location of the I-th node. XN(1) is XL, % and XN(N+1) is XR. % fprintf ( 1, '\n' ); fprintf ( 1, 'Computed solution:\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Node X(I) U(X(I))\n' ); fprintf ( 1, '\n' ); for i = 0 : nsub if ( i == 0 ) if ( ibc == 1 | ibc == 3 ) value = ul; else value = u(indx(i+1)); end elseif ( i == nsub ) if ( ibc == 2 | ibc == 3 ) value = ur; else value = u(indx(i+1)); end else value = u(indx(i+1)); end fprintf ( 1, ' %6d %12f %12f\n', i, xn(i+1), value ); end