Class5

From MathWiki

The 5th assignment Media:Ass5.pdf

Couple of notes:

  • I said that the construction in Octave for an if statement had a then in it. This was incorrect the format for an if statement should be:

if condition

statement

else

statement

end

  • Some people found that their commands were not working unless they had a semi-colon at the end of each line. I tried it and I did not have this problem. I don't know whats up with that.
  • I forgot to tell you how to save in Octave. First, if you use the uparrows, Octave should keep a history of your previous commands, even between different sessions. Read the sections on command line editing in the documentation of Octave (http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Editing.html#Command-Line-Editing). I am going to look into how to write information to a text file and load the commands. This should be possible in Octave, but I don't know how to do it yet.


Class Summary by Paul Aniceto:

Given a matrix A=

123 456 789

[1,2,3; 4,5,6; 7,8,9]

(sorry guys...for some reason the matrix looks neat when I am typing it out but comes out as one single row when I save changes...will include 1-line octave command for matrix just incase.)

if you want to move the entries to the left and have the last entry turn to zeros, you will need to use matrix multiplication.

Namely,

123 456 789

mult by.

000 100 010

[0,0,0;1,0,0; 0,1,0]

on the right-hand-side

and you get:

230 560 890

[2,3,0; 5,6,0;8,9,0]

If you want to shift your matrix A downwards you would multiply A by:

000 100 010

[0,0,0; 1,0,0;0,1,0]

on the left-hand-side and get:

000 123 456

[0,0,0;1,2,3;4,5,6]

If you want to rotate matrix A to the left you would multiply A by:

001 100 010

[0,0,1; 1,0,0; 0,1,0]

on the right.

Rotate (shift entries downwards with a 'wrap around') you would multiply A by:

001 100 010

[0,0,1;1,0,0;0,1,0]

on the left-hand-side.

The rest of the class we took up some problems that we worked on in our assignments and Mike gave us some hints. My notes here are not very clear because Mike did a lot of proving by 'erasing' :-) by his own admission. So please do your best to follow.

Question: Finding components of 2 colours.

  *---------------*-----------*

(x1,y1) (x,y) (x2,yx)

a1+a2=1 0<=a1, a2<=1

want: (x,y)=a1(x1,y1)+a2(x2,y2)

find: a1 and a2 in terms of x1, y1x2, y2, x1y

a1 + a2 = 1

x= a1x1+a2x2

y= a1y1+a2y2


Question 3 on Assignment #3:

Make this problem into a linear Algebra problem...

a1+a2+a3=1

x=a1x1+a2x2+a3x3

y=a1y1+a2y2+a3y3

[1,1,1; x1,x2,x3; y1,y2,y3] * [a1;a2;a3] = [1;x;y]

[a1;a2;a3] = [1,1,1; x1,x2,x3; y1,y2,y3]^-1 * [1;x;y]

Octave can do this...

Miscellaneous Octave/GIMP Trick(s):

Octave:

diag([1,2,3]) =

100 020 003

It puts 1,2,3 along the matrix diagonal and zeros everywhere else.

Gimp:

To do the colour fin 'switch'...you can do this on GIMP by using the 'filters' tab and clicking on decompose...(the 3 dots at the end indicates that another dialogue menu will show up).

You can also use the Filters tab and then 'compose...' and switch the colours.