Monday, May 26, 2008

assignment #4

19) shift the entries of a matrix A one place left
A = [1,1,0;0,1,0;1,0,0;1,1,1];
for i=1:3
temp(i)=A(i,1)
endfor;
31 for i=1:3
for j=2:3
A(i,j-1)= A(i,j)
endfor;
32 for i=1:3
A(i,3)=temp(i)
endfor;
the matrix A will be 1 0 1
1 0 1
0 0 1
1 1 0
20) shift the entries of a matrix A one place down(wrapping around bottom to top)
consider a matrix A = [2,3,4;5,6,7;8,9,0]
by octave command matrix A= 2 3 4
5 6 7
8 9 0
octave command shift(a,1)
and answer will be A= 8 9 0
2 3 4
5 6 7
21) Shift the entries of a matrix A one place left
let matrix A= [2,3,4;5,6,7;8,9,0]
and matrix B= [0,0,1;1,0,0;0,1,0]
third octave command A*B
3 4 2
6 7 5
9 8 0

22) shift the entries of matrix A one place down
let matrix a=[2,3,4;5,6,7;8,9,0]
and matrix b=[0,0,0;1,0,0;0,1;0]
b*a = [0,0,0;2,3,4;5,6,7] all these are octave command

No comments: