# Matlab

Disponible uniquement sur Etudier
• Pages : 3 (551 mots )
• Téléchargement(s) : 0
• Publié le : 19 mai 2010

Aperçu du document
Matlab

. . . ... 233 144 89 55 34 21 13 8 5 3 2 1 1 0 : .

. 1 2 4 2 5 10 0 -1 -1

.
sin, cos, log, exp, tan, atan, 1/x, 1/log(x), 1/x
3

1

Matlab

. ( ) .

functionExercice_N1() a=input('Please choose a number. a =') if (mod(a,2)==0) sprintf('%d is an odd number.',a) else sprintf('%d is an even number',a) end end

.

1 2

3

function Exercice_N2() clc a =input('Please choose 1st number. a ='); b = input('Please choose 2nd number. b ='); temp=a; a=b; b=temp; sprintf('a = %d',a) sprintf('b = %d',b) end

.

.

2

Matlab

function Exercice_N3V0()a = input('Please choose 1st number. a ='); b = input('Please choose 2nd number. b ='); c = input('Please choose 3rd number. c ='); if (ab & a>c sprintf('%d < %d < %d',b ,c ,a ) end end end endfunction Exercice_N3V1() a = input('Please choose 1st number. a ='); b = input('Please choose 2nd number. b ='); c = input('Please choose 3rd number. c ='); if (ab & a>c Show(b ,c ,a ) end end endend function Show(a,b,c) sprintf('%d < %d < %d',a ,b ,c ) end

3

Matlab
sort

.
function Exercice_N3V1() a = input('Please choose 1st number. a ='); b = input('Please choose 2nd number. b='); c = input('Please choose 3rd number. c ='); Vector =[a,b,c]; Sorted_Vector = sort(Vector); Show(Sorted_Vector(1), Sorted_Vector(2), Sorted_Vector(3)) end

... 233 144 89 55 34 21 13 8 5 3 21 1 0 : . ... 0,1,2,3

.

function Exercice_N4() max=input('Please choose the series length: '); Vector = [0:max]; for i=3:max+1 Vector(i) = Vector(i-1) + Vector(i-2); end Vector end

. 1 24 2 5 10 0 -1 -1

1 0 0 : 0

0 1 0 : 0

0 0 1 : 0

0 0

1

4

Matlab

function Exercice_N5() A = [1 2 0; 2 5 -1; 4 10 -1] Transpose_A= A' Multiplication_1= A*A' Multiplication_2=A.*A' Inverse_A= inv(A) I=inv(A)*A Eigenvalues_A = eig(A) singular_value_decomposition=svd(A) Characterisitic_polynomial_A = round(poly(A)) eig_original=roots(Characterisitic_polynomial_A)...