You are on page 1of 14

esercizi sulle matrici: --> A=[1:+2:5;2:+2:6;1 2 3]

A = 1 3 5 2 4 6 1 2 3

--> size(A)

ans = 3 3

--> size(8)

ans = 1 1

--> V=A(1:3)

V = 1 2 1

--> V= A(2,1:3)

V = 2 4 6

--> length(v) Error: Undefined function or variable v

--> length(a(2,1:3)) Error: Undefined function or variable a --> length(A(2,1:3))

ans = 3

--> trill(A) Error: Undefined function or variable trill --> tril(A) Error: Undefined function or variable tril --> tril(A) Error: Undefined function or variable tril --> triu(A) Error: Undefined function or variable triu --> tril(A) Error: Undefined function or variable tril --> tril(V) Error: Undefined function or variable tril --> A=[1:+2:5,1;2:+2:6,1;1 2 3 1]

A = 1 3 5 1 2 4 6 1 1 2 3 1

--> A=[1:+2:5,1;2:+2:6,1;1 2 3 1;1 1 1 1]

A = 1 3 5 1

2 4 6 1 1 2 3 1 1 1 1 1

--> A=[1:+2:5,1;2:+2:6,1;1 2 3 1;ones(1,4)]

A = 1 3 5 1 2 4 6 1 1 2 3 1 1 1 1 1

--> tril(A,-1) Error: Undefined function or variable tril --> tril(A,-2) Error: Undefined function or variable tril --> tril(A,-3); Error: Undefined function or variable tril --> triu(A,1) Error: Undefined function or variable triu --> diag(A)

ans = 1 4 3 1

--> diag(A,1)

ans = 3 6 1

--> diag(V)

ans = 2 0 0 0 4 0 0 0 6

--> triu(diag(V)) Error: Undefined function or variable triu --> diag(V,1)

ans = 0 2 0 0 0 0 4 0 0 0 0 6 0 0 0 0

--> diag(V,4)

ans = 0 0 0 0 2 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0

--> diag(V,-2)

ans = 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 4 0 0 0 0 0 6 0 0

--> ones(4,4)

ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

--> ones(3,5)

ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

--> eye(7)

ans =

1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1

--> sum(V)

ans = 12

--> v' Error: Undefined function or variable v --> sum(v') Error: Undefined function or variable v --> sum(A)

ans = 5 10 15 4

--> sum(A,2)

ans = 10 13 7 4

--> sum(A,1)

ans = 5 10 15 4

--> sum(sum(A))

ans = 34

--> prod(V)

ans = 48

--> prod(A)

ans = 2 24 90 1

--> prod(A,2)

ans = 15 48 6 1

--> det(A)

ans = 0

--> A(4,3)=5

A = 1 3 5 1 2 4 6 1 1 2 3 1 1 1 5 1

--> det(A)

ans = 4

--> B=inv(A)

B = -1,7500 0,5000 0,2500 0 1,0000 0 0 -1,0000 0,5000 0 -0,5000 2,0000 0,2500 -0,5000 0,2500 0

--> B*A

ans = 1 0 0 0 0 1 0 0 0 0 1 0

0 0 0 1

--> det(inv(A))

ans = 0,2500

--> det(A)*det(B)

ans = 1,0000

--> V

ans = 2 4 6

--> V=(V,1,1,1,4,5) Error: Unexpected input

V=(V,1,1,1,4,5) ^ --> V=[V,1,1,1,4,5]

V = 2 4 6 1 1 1 4 5

--> norm(V,inf)

ans =

--> norm(V,1)

ans = 24

--> Y=abs(V)

Y = 2 4 6 1 1 1 4 5

--> sum(Y)

ans = 24

--> norm(V)

ans = 10

--> abs(V).^2

ans = 4 16 36 1 1 1 16 25

--> sqrt(sum(abs(V).^2))

ans =

10

--> norm(A,inf)

ans = 13

--> norm(A,1)

ans = 19

--> norm(A',1)

ans = 13

--> norm(A)

ans = 11,5172

--> norm(A,f) Error: Undefined function or variable f --> norm(A,'fro')

ans = 11,6619

--> norm(eye(A))

In /usr/share/freemat/toolbox/matrix/eye.m(eye) at line 15 In docli(builtin) at line 1 In base(base) In base() In global() Error: Dimension arguments must be either all scalars or a single vector --> norm(eye(sqrt(5)))

ans = 1

--> max(V)

ans = 6

--> min(V)

ans = 1

--> help max

MAX MAX Maximum Function

Usage

Computes the maximum of an array along a given dimension, or alternate ly, computes two arrays (entry-wise) and keeps the smaller value for each array.

As a result, the max function has a number of syntaxes. The first one computes the maximum of an array along a given dimension. The first general syntax for its use is either

[y,n] = max(x,[],d)

where x is a multidimensional array of numerical type, in which case t he output y is the maximum of x along dimension d. The second argument n is the index that results in the maximum. In the event that multiple maxima are present with the same value, the index of the first maximum is used. The second general syntax for the use of the max function is

[y,n] = max(x)

In this case, the maximum is taken along the first non-singleton dimension of x. For complex data types, the maximum is based on the magnitude of the numbers. NaNs are ignored in the calculations. The third general syntax for the use of the max function is as a comparison function for pairs of arrays. Here, the general syntax i s

y = max(x,z)

where x and z are either both numerical arrays of the same dimensions, or one of the two is a scalar. In the first case, the output is the same size as both arrays, and is defined elementwise by the smaller of the two arrays. In the second case, the output is defined elementwise by the

-->

You might also like