pasar codigo de matlab a python
Publicado por Andre (2 intervenciones) el 16/11/2019 20:47:12
buenas.
por favor necesito pasar este codigo que esta en matlab a python
gracias
por favor necesito pasar este codigo que esta en matlab a python
gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
clc, clear, close all
% a b c d e f g
P =[1 1 1 1 1 1 0; %0
0 1 1 0 0 0 0; %1
1 1 0 1 1 0 1; %2
1 1 1 1 0 0 1; %3
0 1 1 0 0 1 1; %4
1 0 1 1 0 1 1; %5
1 0 1 1 1 1 1; %6
1 1 1 0 0 0 0; %7
1 1 1 1 1 1 1; %8
1 1 1 1 0 1 1]; %9
P = P';
nparx = [1 0 1 0 1 0 1 0 1 0]; % Numeros pares
nmay = [0 0 0 0 0 0 1 1 1 1]; % Mayores a 5
nprim = [0 0 1 1 0 1 0 1 0 0]; % Numeros Primos
n = [1 0 1 0 1 0 1 0 1 0;
0 0 0 0 0 0 1 1 1 1;
0 0 1 1 0 1 0 1 0 0];
D = 2*rand(3,7)-1;
m = 2*rand(3,1)-1;
e = [1 0 1 0 1 0 1 0 1 0;
0 0 0 0 0 0 1 1 1 1;
0 0 1 1 0 1 0 1 0 0];
for Epocas = 1:200
for q = 1:10
e(:,q) = n(:,q) - hardlim(D*P(:,q) + m);
D = D + e(:,q)*P(:,q)';
m = m + e(:,q);
end
end
for q = 1:10
hardlim(D*P(:,q) + m)
end
Valora esta pregunta


0