>> % MATLAB Recitation Demo for Tuesday, September 23. >> % File: rdemo3 >> % >> % *** Computing the nullspace of A via nullbasis(A). >> % *** Display formats: format short and format rat. >> % >> % >> % *** From the Athena Dash menu, start MATLAB using >> % *** Courseware / 18 Mathematics / 18.06 / 18.06 MATLAB >> % *** Otherwise, MATLAB will not be able to find the new >> % *** command "nullbasis" - which is demonstrated below. >> % >> % Remarks: By default, MATLAB results are displayed in a >> % scaled fixed point format with 5 digits. >> % We can display results as fractions by using the command >> % format rat. >> % 'help format' gives additional details and formats. >> % >> % The MATLAB command nullbasis(A) computes a matrix whose columns >> % are "special" solutions to Ax = 0. >> % These solutions express the zero vector as 1 * free column + >> % some linear combination of the previous pivot columns. >> % >> diary rdemo3 >> >> % Let's compute the nullspace of the following 3 by 5 matrix A. >> % For comparison, we also compute its reduced row echelon form. >> % Can you see how the nonzero entries in the free columns are >> % related to the entries in the "special" solutions?! >> >> A = [-1 3 8 -2 1; -1 3 9 -1 3; 1 -3 -9 1 -3] A = -1 3 8 -2 1 -1 3 9 -1 3 1 -3 -9 1 -3 >> Z = nullbasis(A) Z = 3 -10 -15 1 0 0 0 -1 -2 0 1 0 0 0 1 >> R = ref(A) R = 1 -3 0 10 15 0 0 1 1 2 0 0 0 0 0 >> % >> %%%%%%%%%%%%%%%%%%%%%%% >> %%% Another Example %%% >> %%%%%%%%%%%%%%%%%%%%%%% >> % >> A = [24 8 -3 3 0 13; 24 8 -3 4 4 16] A = 24 8 -3 3 0 13 24 8 -3 4 4 16 >> Z = nullbasis(A) Z = -0.3333 0.1250 0.5000 -0.1667 1.0000 0 0 0 0 1.0000 0 0 0 0 -4.0000 -3.0000 0 0 1.0000 0 0 0 0 1.0000 >> % >> %%% Use format rat to display entries as fractions. >> % >> format rat >> Z Z = -1/3 1/8 1/2 -1/6 1 0 0 0 0 1 0 0 0 0 -4 -3 0 0 1 0 0 0 0 1 >> % >> %%% With practice, you should be able to inspect the reduced >> %%% row echelon form and determine the "special" solutions. >> % >> R = ref(A) R = 1 1/3 -1/8 0 -1/2 1/6 0 0 0 1 4 3 >> diary off