感知器算法matlab代码
时间: 2023-10-06 20:10:47 浏览: 177
感知器算法Matlab源码
5星 · 资源好评率100%
感知器算法的MATLAB代码如下:
```MATLAB
function w = perception(x)
w(1,:) = [0,0,0];
k = 0;
n = 0;
size1 = size(x);
for i = 1:100
for j = 1:size1(1)
k = k + 1;
if w(k,:) * x(j,:)' > 0
n = n + 1;
w(k + 1,:) = w(k,:);
else
w(k + 1,:) = w(k,:) + x(j,:);
end
end
if n >= (size1(1))
break;
else
n = 0;
end
end
w = w(k + 1,:);
end
```
阅读全文