[討論] ANFIS我是check了不過很怕有錯~可以請大大們幫我看一下嗎謝已回收
clear all; clc
rand('seed',200);
excelmat1=xlsread('Taichungdata1003');
kp=1690; ma=2100; rt=13;incap=72*1000;
maty1=size(excelmat1,1); matx1=size(excelmat1,2);
%*****************************資料正規化**********************************
pp=excelmat1(:,1); pmax4=max(pp); pmin4=min(pp);
dn4=(0.8 .* (pp-pmin4)./(pmax4-pmin4)) + 0.1;
light2=excelmat1(:,3); pmax5=max(light2); pmin5=min(light2);
dn5=(0.8 .* (light2-pmin5)./(pmax5-pmin5)) +0.1;
time=excelmat1(:,2);
%*****************************資料正規化**********************************
%****************************資料整理*************************************
Data=[dn4(1:ma) time(2:ma+1) dn5(1:ma) dn4(2:ma+1)]; %Data=[輸入1=發電量前一筆,輸入2=時間當筆,輸入3=照度前一筆,輸出3=發電量當筆]
trnData=Data(1:kp,:); %訓練用資料
chkData=Data(kp-1:ma-1,1:3); %測試用資料
%****************************資料整理*************************************
%****************************輸入隸屬度和類型及形成模糊推論系統*************
numMFs = [2 2 2]; %依案例不同要有所誤試
imfType=str2mat('gaussmf','gaussmf','gaussmf'); %三輸入隸屬度類型高斯,高斯,高斯
fisMat1=genfis1(trnData,numMFs,imfType); %形成模糊推理系?要修改
%****************************輸入隸屬度和類型及形成模糊推論系統*************
% *****************************類神經網路*******************************
epoch_n=10;
fisMat=anfis(trnData,fisMat1,epoch_n);
legend('Training Data','ANFIS Output'); %圖表註解
% *****************************類神經網路*******************************
% *****************************預測及誤差*******************************
for j=kp:ma
forecast=evalfis(chkData, fisMat);
yy(j)=((forecast(j-(kp-1))-0.1)*(pmax4-pmin4)/0.8)+pmin4;
error(j)=(abs((yy(j))-pp(j))./incap);
end
xx1=sum(error)/length(error);
xx1
for jj=1:length(yy)
if yy(jj)<0
yy(jj)=0;
end
yy;
end
ii=kp:ma;
figure(1)
plot(ii-kp,pp(ii),ii-kp,yy(ii))
% *****************************預測及誤差*******************************
%****************************輸入隸屬度圖型*******************************
figure(2)
subplot(3,1,1);plotmf(fisMat1,'input',1);
subplot(3,1,2);plotmf(fisMat1,'input',2);
subplot(3,1,3);plotmf(fisMat1,'input',3);
figure(3)
subplot(3,1,1);plotmf(fisMat,'input',1);
subplot(3,1,2);plotmf(fisMat,'input',2);
subplot(3,1,3);plotmf(fisMat,'input',3);
%****************************輸入隸屬度圖型*******************************
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.42.221
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章