Tools used in this article: vc6.0+matlab6.5
In this chapter is achieved in the VC call Matlab Neural Network Toolbox, the article used in the program is a master's thesis part, so did not provide source program, the purpose is through this example to introduce how to use the VC COM components to achieve VC and MATLAB data exchange. First in the MATLAB to complete two neural network functions, one to test, one to predict.
1. Check function:
function [w1,b1,w2,b2,ET,a2]=SJHSJY(P,T,me,eg,lr,P2,T2,S1)
[Pn,meanp,stdp,Tn,meant,stdt]=prestd(P,T); %预处理
[w1,b1,w2,b2]=initff(Pn,S1,''tansig'',Tn,''purelin''); %数据初始化
df=10;
tp=[df me eg lr];
[w1,b1,w2,b2,tp,tr]=trainbpx(w1,b1,''tansig''); %样本训练
P2n=trastd(P2,meanp,stdp);
......后处理 %必须为非负
This function is the test error of BP neural network, the P,T,ME,EG,LR,P2,T2,S1 is the input parameter; W1,B1,W2,B2,ET,A2 is the output parameter.
2. Predictive function:
function [a2]=SJHSYC(P,T,P2,me,eg,lr,S1)
[Pn,meanp,stdp,Tn,meant,stdt]=prestd(P,T);
[w1,b1,w2,b2]=initff(Pn,S1,''tansig'',Tn,''purelin'');
........
参数输出
P,T,ME,EG,LR,P2,T2,S1 for the input parameter A2 as an output parameter, which is the desired result
3, in the MATLAB in the two functions into COM components, specific methods can refer to VC and MATLAB joint programming < three >.
4, the new VC based on the Dialogue box project, the introduction of COM components in VC, specific methods can be referred to VC and MATLAB joint programming < Three, after the completion of the ClassView can see more than two new classes Isjhsjy and ISJHSYC, as shown in Figure 1, They implement functions sjhsjy.m and SJHSYC.M respectively.
Figure 1
Look closely at the parameters of the class Isjhsjy, as shown in Figure 2
Figure 2