Informatics1-2017/HW6

A MathWikiből

Tartalomjegyzék

Getting the program

Use one of the following from home:

  • install Octave, free for all platforms
  • using putty log in to leibniz, start octave with the octave command
  • run octave from the computer lab

How to hand in

Just send a text file with the commands to the usual email address.

Tasks

Large matrix

  • Create the following matrix using the least characters you can:
1 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2
2 2 3 2 2 2 2 2 2 2
2 2 2 4 2 2 2 2 2 2
2 2 2 2 5 2 2 2 2 2
2 2 2 2 2 6 2 2 2 2
2 2 2 2 2 2 7 2 2 2
2 2 2 2 2 2 2 8 2 2
2 2 2 2 2 2 2 2 9 2
2 2 2 2 2 2 2 2 2 10
  • Same as before:
 0  1  0  0  0  0  0  0  0
-1  0  1  0  0  0  0  0  0
 0 -1  0  1  0  0  0  0  0
 0  0 -1  0  1  0  0  0  0
 0  0  0 -1  0  1  0  0  0
 0  0  0  0 -1  0  1  0  0
 0  0  0  0  0 -1  0  1  0
 0  0  0  0  0  0 -1  0  1
 0  0  0  0  0  0  0 -1  0
  • Chessboard
  1  -1   1  -1   1
 -1   1  -1   1  -1
  1  -1   1  -1   1
 -1   1  -1   1  -1
  1  -1   1  -1   1

Function on matrices

Write a function that applies the function 2sin2x + 1 to every element of a given matrix.

Part of a matrix

Write a function that separates a 5x5 matrix into a 2x5 matrix with the 2nd and 4th row, and a 3x5 with the 1st, 3rd, 5th.

Part of a matrix function

Combine the previous two so that the function applies the 2sin2x + 1 function to both new matrices.

Every second column

Write a function that outputs the matrix with every second column skipped in the input matrix. (Help, size can help with the dimension of the matrix.)

Applying a function to elements

Write a function that applies the function 2sin2x + 1 to every second column of a matrix.

Tests

When the task is to write a function test (call) the function as well.

Személyes eszközök