📄 bpx_simu.m
字号:
%此为一仿真程序
%首先读入权域值参数
function retdouble = simulate(NetPara,SimulatePara,InputFun,OutputFun,DataDir)
NNTWARN OFF
retdouble = -1;
olddir=pwd;
% 数据所在目录
cd(DataDir);
% 输入层到中间层的传递函数
if (length(InputFun)==0)
InputFun = 'tansig';
end
% 中间层到输出层的传递函数
if (length(OutputFun)==0)
OutputFun = 'purelin'
end
frw1=fopen('w1.dat','r');
frb1=fopen('b1.dat','r');
frw2=fopen('w2.dat','r');
frb2=fopen('b2.dat','r');
InputDim=NetPara(1); %输入层节点数
OutputDim=NetPara(2); %输出层节点数
MidDim=NetPara(3); %中间层节点数
[w1,count]=fscanf(frw1,'%f',[MidDim,InputDim]);
[b1,count]=fscanf(frb1,'%f',[MidDim,1]);
[w2,count]=fscanf(frw2,'%f',[OutputDim,MidDim]);
[b2,count]=fscanf(frb2,'%f',[OutputDim,1]);
fclose(frw1);
fclose(frb1);
fclose(frw2);
fclose(frb2);
for i=1:InputDim
p1(i)=SimulatePara(i);
end
a=simuff(p1',w1,b1,InputFun,w2,b2,OutputFun);
%将仿真结果写入文件
fwresult=fopen('result.dat','w');
fprintf(fwresult,'%-15.6f\n',a);
fclose(fwresult);
retdouble = a;
logsig(1);
purelin(1);
tansig(1);
cd(olddir);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -