以下是一个简单的模糊神经网络的MATLAB程序:

% 定义输入和输出的模糊集合 input1 = newfis('input1'); input1 = addvar(input1, 'input', 'x', [-10 10]); input1 = addmf(input1, 'input', 1, 'negative', 'trimf', [-10 -10 0]); input1 = addmf(input1, 'input', 2, 'zero', 'trimf', [-10 0 10]); input1 = addmf(input1, 'input', 3, 'positive', 'trimf', [0 10 10]);

output1 = newfis('output1'); output1 = addvar(output1, 'output', 'y', [-5 5]); output1 = addmf(output1, 'output', 1, 'negative', 'trimf', [-5 -5 0]); output1 = addmf(output1, 'output', 2, 'zero', 'trimf', [-5 0 5]); output1 = addmf(output1, 'output', 3, 'positive', 'trimf', [0 5 5]);

% 定义模糊规则 rule1 = [1 1 1 1; 2 2 2 1; 3 3 3 1];

% 创建模糊神经网络 fuzzy_nn = newfnn(input1, output1, rule1);

% 训练模糊神经网络 x = -10:0.1:10; y = sin(x); fuzzy_nn = anfis([x' y'], fuzzy_nn);

% 使用训练好的模型进行预测 x_test = -5:0.1:5; y_test = evalfis(x_test, fuzzy_nn); plot(x, y, 'b', x_test, y_test, 'r'); legend('原始数据', '预测结果'); xlabel('x'); ylabel('y'); title('模糊神经网络的预测结果');

模糊神经网络的MATLAB的程序

原文地址: http://www.cveoy.top/t/topic/blYm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录