Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matlab ones(1,5); %1 1 1 1 1 zeros(1,5); %0 0 0 0 0 1:5; %1 2 3 4 5 1:2:9; %1 3 5 7 9 linspace(0,1,5) ; %0 0.2500 0.5000 0.7500.

Similar presentations


Presentation on theme: "Matlab ones(1,5); %1 1 1 1 1 zeros(1,5); %0 0 0 0 0 1:5; %1 2 3 4 5 1:2:9; %1 3 5 7 9 linspace(0,1,5) ; %0 0.2500 0.5000 0.7500."— Presentation transcript:

1

2

3

4

5

6

7

8

9

10

11

12

13 Matlab ones(1,5); % zeros(1,5); % :5; % :2:9; % linspace(0,1,5) ; % rand(1,5); %0.xxxx 0.xxxx 0.xxxx 0.xxxx 0.xxxx a=[1 2 ; 3 4]; a(2,2); %4 matriz(nºfila,nº columna) a(1,: ); %fila 1 a(:,2); %columna 2 a(2,2:end); %2ª a última columna de fila 2 a*a; %[7 9; 15 22] multiplicación de matrices a.*a;%[1 4;9 16] punto a punto

14

15

16 Raiz de función continua Matlab function r=raiz(a,b,eps) x=(a+b)/2; if b-a <= eps r=x; elseif f(x)*f(a) >= 0 r=raiz(x,b,eps); else r=raiz(a,x,eps); end Python: def raiz(f,a,b,eps): x=(a+b)/2.0 if b-a <= eps: return x elif f(x)*f(a)>=0: return raiz(f,x,b,eps) else: return raiz(f,a,x,eps)

17 Sistema de n ecuaciones lineales a 11 x 1 + a 12 x a 1n x n = b 1... a n1 x 1 + a n2 x a nn x n = b n Matlab A=[…; … ; … ]; %matriz de coeficientes a(i,j) B=[nº; nº ; …;nº]; %vector de b(i) X=inv(A)*B; %X=A\B; Python A=[[…],…,[…]] #matriz de coeficientes a(i,j) B=[nº, nº, …,nº] #vector de b(i) triangularizar(a,b) x=[0]*n for i in range(n-1,-1,-1): suma=0.0 for j in range(i+1,n): suma += x[j]*a[i][j] x[i] = (b[i]-suma)/a[i][i]

18 Multiplicación de matrices Matlab z=x*y; Python def producto(x,y): filas=len(x);cols=len(y[0]);n=length(y) z=[[0]*cols]*filas for i in range(filas): for j in range(cols): for k in range(n): z[i][j] += x[i][k]*y[k][j] return z z=producto(x,y)


Download ppt "Matlab ones(1,5); %1 1 1 1 1 zeros(1,5); %0 0 0 0 0 1:5; %1 2 3 4 5 1:2:9; %1 3 5 7 9 linspace(0,1,5) ; %0 0.2500 0.5000 0.7500."

Similar presentations


Ads by Google