This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/linearalgebra/simulations/matrixbox.m

25 lines
822 B
Matlab

function matrixbox( m )
% visualizes the effect of a matrix m on a set of vectors forming a box
% m: a 2x2 matrix
v = [ 0 1 1 0 0; 0 0 1 1 0];
w = m*v;
clf;
hold on;
%set(gca, 'Xtick', [], 'Ytick', [], 'box', 'off')
% axis:
plot( [-2 2], [0 0], 'k', 'LineWidth', 1 );
plot( [0 0], [-2 2], 'k', 'LineWidth', 1 );
% old box:
plot( v(1,:), v(2,:), 'k', 'LineWidth', 1.0 )
quiver( [v(1,1)], [v(2,1)], [v(1,3)], [v(2,3)], 1.0, 'k', 'LineWidth', 2.0 );
scatter( [v(1,2)], [v(2,2)], 60.0, 'filled', 'k' );
% transfomred box:
plot( w(1,:), w(2,:), 'b', 'LineWidth', 2.0 )
quiver( [w(1,1)], [w(2,1)], [w(1,3)], [w(2,3)], 1.0, 'b', 'LineWidth', 3.0 );
scatter( [w(1,2)], [w(2,2)], 100.0, 'filled', 'b' );
hold off;
xlim( [ -2 2 ] );
ylim( [ -2 2 ] );
end