├── .gitignore ├── README.md ├── ch02 ├── code │ ├── batch_pic_process.m │ ├── cust_plot.m │ └── database_example.m └── data │ ├── images │ ├── 1_1.jpg │ ├── 1_2.jpg │ ├── 1_3.jpg │ ├── 1_4.jpg │ └── 1_5.jpg │ └── time_series.xls ├── ch03 ├── code │ ├── correlation_analyze.m │ ├── de_missing_abnormal.m │ ├── dish_pareto.m │ ├── missing_abnormal_check.m │ └── statistics_analyze.m └── data │ ├── catering_dish_profit.xls │ ├── catering_fish_congee.xls │ ├── catering_sale.xls │ └── catering_sale_all.xls ├── ch04 ├── code │ ├── abnormal_rules_1.m │ ├── cust_subplot.m │ ├── data_discretization.m │ ├── data_normalization.m │ ├── de_abnormal.m │ ├── find_type.m │ ├── lagrange_interp.m │ ├── lagrange_newton_interp.m │ ├── line_rate_construct.m │ ├── newton_interp.m │ ├── ployinterp_column.m │ ├── principal_component_analyze.m │ └── wave_analyze.m └── data │ ├── catering_sale.xls │ ├── discretization_data.xls │ ├── electricity_data.xls │ ├── normalization_data.xls │ └── principal_component.xls ├── ch05 ├── code │ ├── ID3_decision_tree.m │ ├── arima_test.m │ ├── bp_neural_network.m │ ├── bp_preprocess.m │ ├── cal_apriori.m │ ├── discrete_point_test.m │ ├── findRules.m │ ├── id3.m │ ├── id3_preprocess.m │ ├── k_means.m │ ├── logistic_regression.m │ ├── print_tree.m │ ├── queue_curr_size.m │ ├── queue_pop.m │ ├── queue_push.m │ ├── trans2matrix.m │ └── tree_plot.m └── data │ ├── arima_data.xls │ ├── bankloan.xls │ ├── consumption_data.xls │ ├── menu_orders.txt │ └── sales_data.xls ├── ch06 ├── code │ ├── Lagrange_interpolation.m │ ├── construct_dt_model.m │ ├── construct_lm_model.m │ ├── ployinterp_column.m │ ├── polyinterp.m │ ├── split2train_test.m │ ├── split_data.m │ └── test_lm_dt_model.m ├── data │ ├── missing_data.xls │ ├── model.xls │ ├── test_model.xls │ ├── train_model.xls │ ├── 拓展思考样本数据.xls │ └── 窃漏电构建模型输入数据.xls └── tmp │ ├── lm_train_output_data.xls │ ├── missing_data_processed.xls │ ├── net.mat │ ├── test_model.xls │ └── train_model.xls ├── ch07 ├── code │ ├── data_clean.m │ ├── data_explore.m │ ├── filter_data.m │ ├── find_empty.m │ ├── kmeans_cluster.m │ ├── log_add.m │ └── zscore_data.m └── data │ ├── air_data.csv │ ├── zscoredata.xls │ └── zscoreddata.xls ├── ch08 ├── code │ ├── apriori_rules.m │ ├── discretization.m │ ├── filter_rules.m │ ├── findRules.m │ └── trans2matrix.m └── data │ ├── apriori.txt │ └── data.xls ├── ch09 ├── code │ ├── color_moment_extract.m │ ├── construct_lm_model.m │ ├── picture_slicer.m │ ├── split2train_test.m │ ├── split_data.m │ └── test_lm_model.m └── data │ ├── 1_1.jpg │ ├── 1_1_processed.jpg │ ├── moment.xls │ ├── test_moment.xls │ └── train_moment.xls ├── ch10 ├── code │ ├── cust_ksdensity.m │ ├── extract_visit_data.m │ ├── findRules.m │ ├── preprocess_apriori.m │ ├── test.m │ ├── test_apriori.m │ ├── test_kmeans.m │ ├── trans2matrix.m │ └── z_score_cluster_data.m └── data │ ├── cluster_data.xls │ ├── raw_data.xls │ └── visit_data.xls ├── ch11 ├── code │ ├── arima_model_check.m │ ├── attribute_transform.m │ ├── cal_errors.m │ ├── find_optimal_pq.m │ ├── stationarity_test.m │ └── whitenoise_test.m └── data │ ├── discdata.xls │ ├── discdata_processed.xls │ └── predictdata.xls ├── ch12 ├── code │ ├── cal_correlation.m │ └── cal_weight_consistency_rate.m └── data │ ├── addedwords_11.xls │ ├── address_4.xls │ ├── identity_5.xls │ ├── name_2.xls │ ├── paired_comparision.xls │ ├── phone_6.xls │ ├── qq_8.xls │ ├── score.xls │ ├── sex_3.xls │ ├── sum_words.xls │ └── user_information.xls ├── ch13 ├── code │ ├── divide_event.m │ ├── divide_event_for_optimization.m │ ├── test_neural_network.m │ ├── threshold_optimization.m │ ├── train_neural_network.m │ └── train_neural_network_bak.m └── data │ ├── neural_network_data.xls │ ├── original_data.xls │ ├── test_neural_network_data.xls │ └── water_heater.xls ├── ch14 ├── code │ ├── hierarchical_clustering.m │ ├── hierarchical_clustering_pic.m │ ├── plotrows.m │ ├── rotateticklabel.m │ ├── standardization.m │ └── subplotrows.m └── data │ ├── business_circle.xls │ └── standardized.xls ├── ch15 ├── code │ ├── attr_state_count.m │ ├── bar_line_plot.m │ ├── constructChildren.m │ ├── data_exploration.m │ ├── evaluateAttr.m │ ├── hotspot.m │ ├── hs_preprocess.m │ ├── m_rules_containkey.m │ ├── node_2_string.m │ ├── print_hsnode.m │ ├── queue_push.m │ ├── queue_sort.m │ └── test_hotspot_bird.m └── data │ ├── defectdata.xls │ ├── hotspotdata.xls │ └── weatherdata.xls └── ch16 ├── java_code └── lm_net_classify_class.java └── matlab_code ├── LMAlgorithm.prj ├── chgicon.m ├── deltalin.m ├── deltatan.m ├── dlogsig.m ├── dpurelin.m ├── dtansig.m ├── learnlm.m ├── lmNetClassify.m ├── lmNetPredict.m ├── lmNetStructure.m ├── lmNetTest.m ├── lmNetTrain.m ├── lm_bp.m ├── logsig.m ├── nnet ├── nncontrol │ ├── Contents.m │ ├── ball1.mat │ ├── ballrepel0.mdl │ ├── calcjjdjj.m │ ├── csrchbac.m │ ├── csrchbre.m │ ├── csrchcha.m │ ├── csrchgol.m │ ├── csrchhyb.m │ ├── cstr.mdl │ ├── cstr1.mat │ ├── cstr2.mat │ ├── cstr3.mat │ ├── dnetinv.m │ ├── dyduvar.m │ ├── mrefrobotarm.mdl │ ├── mrefrobotarm2.mdl │ ├── narmamaglev.mdl │ ├── netinv.m │ ├── nncontrolutil.m │ ├── predball.mdl │ ├── predcstr.mdl │ ├── predopt.m │ ├── private │ │ ├── calcgradxmodref.m │ │ ├── calcgxmodref.m │ │ ├── calcperf2.m │ │ ├── nndataexport.m │ │ ├── nndataexporthelp.m │ │ ├── nndataimport.m │ │ ├── nndataimporthelp.m │ │ ├── nnexport.m │ │ ├── nnexporthelp.m │ │ ├── nnident.m │ │ ├── nnidenthelp.m │ │ ├── nnimport.m │ │ ├── nnimporthelp.m │ │ ├── nnmodref.m │ │ ├── nnmodrefhelp.m │ │ ├── nnpredict.m │ │ └── nnpredicthelp.m │ ├── ptest3sim2.mdl │ ├── robot1.mat │ ├── robot1norm.mat │ ├── robot1ref.mat │ ├── robot2.mat │ ├── robot2norm.mat │ ├── robot3norm.mat │ ├── robotarm.mdl │ ├── robotref.mdl │ ├── sfunxy2.m │ ├── srchbacxc.m │ └── trainbfgc.m ├── nndemos │ ├── Contents.m │ ├── appcr1.m │ ├── appelm1.m │ ├── applin1.m │ ├── applin2.m │ ├── choles_all.mat │ ├── demobp1.m │ ├── democ1.m │ ├── demogrn1.m │ ├── demohop1.m │ ├── demohop2.m │ ├── demohop3.m │ ├── demohop4.m │ ├── demolin1.m │ ├── demolin2.m │ ├── demolin4.m │ ├── demolin5.m │ ├── demolin6.m │ ├── demolin7.m │ ├── demolin8.m │ ├── demolvq1.m │ ├── demop1.m │ ├── demop4.m │ ├── demop5.m │ ├── demop6.m │ ├── demopnn1.m │ ├── demorb1.m │ ├── demorb3.m │ ├── demorb4.m │ ├── demos.xml │ ├── demosm1.m │ ├── demosm2.m │ ├── html │ │ ├── democ1.html │ │ ├── democ1_img02.gif │ │ ├── democ1_img03.gif │ │ ├── democ1_img04.gif │ │ ├── demogrn1.html │ │ ├── demogrn1_img02.gif │ │ ├── demogrn1_img03.gif │ │ ├── demogrn1_img04.gif │ │ ├── demogrn1_img05.gif │ │ ├── demohop1.html │ │ ├── demohop1_img03.gif │ │ ├── demohop1_img07.gif │ │ ├── demohop1_img08.gif │ │ ├── demohop2.html │ │ ├── demohop2_img03.gif │ │ ├── demohop2_img06.gif │ │ ├── demohop2_img07.gif │ │ ├── demohop3.html │ │ ├── demohop3_img03.gif │ │ ├── demohop3_img06.gif │ │ ├── demohop3_img07.gif │ │ ├── demohop3_img08.gif │ │ ├── demohop4.html │ │ ├── demolin1.html │ │ ├── demolin1_img03.gif │ │ ├── demolin1_img06.gif │ │ ├── demolin2.html │ │ ├── demolin2_img03.gif │ │ ├── demolin2_img06.gif │ │ ├── demolin2_img07.gif │ │ ├── demolin4.html │ │ ├── demolin4_img03.gif │ │ ├── demolin4_img06.gif │ │ ├── demolin4_img07.gif │ │ ├── demolin5.html │ │ ├── demolin5_img03.gif │ │ ├── demolin5_img06.gif │ │ ├── demolin5_img07.gif │ │ ├── demolin5_img08.gif │ │ ├── demolin6.html │ │ ├── demolin6_img06.gif │ │ ├── demolin7.html │ │ ├── demolin7_img03.gif │ │ ├── demolin7_img06.gif │ │ ├── demolin7_img07.gif │ │ ├── demolin8.html │ │ ├── demolin8_img03.gif │ │ ├── demolin8_img05.gif │ │ ├── demolvq1.html │ │ ├── demolvq1_img03.gif │ │ ├── demolvq1_img05.gif │ │ ├── demolvq1_img06.gif │ │ ├── demop1.html │ │ ├── demop1_img02.gif │ │ ├── demop1_img04.gif │ │ ├── demop1_img05.gif │ │ ├── demop1_img06.gif │ │ ├── demop1_img07.gif │ │ ├── demop4.html │ │ ├── demop4_img02.gif │ │ ├── demop4_img04.gif │ │ ├── demop4_img05.gif │ │ ├── demop4_img07.gif │ │ ├── demop4_img08.gif │ │ ├── demop4_img09.gif │ │ ├── demop5.html │ │ ├── demop5_img02.gif │ │ ├── demop5_img04.gif │ │ ├── demop5_img05.gif │ │ ├── demop5_img07.gif │ │ ├── demop5_img08.gif │ │ ├── demop5_img09.gif │ │ ├── demop6.html │ │ ├── demop6_img02.gif │ │ ├── demop6_img04.gif │ │ ├── demop6_img05.gif │ │ ├── demopnn1.html │ │ ├── demopnn1_img02.gif │ │ ├── demopnn1_img04.gif │ │ ├── demopnn1_img05.gif │ │ ├── demopnn1_img06.gif │ │ ├── demorb1.html │ │ ├── demorb1_img02.gif │ │ ├── demorb1_img03.gif │ │ ├── demorb1_img04.gif │ │ ├── demorb1_img06.gif │ │ ├── demorb3.html │ │ ├── demorb3_img02.gif │ │ ├── demorb3_img04.gif │ │ ├── demorb4.html │ │ ├── demorb4_img02.gif │ │ ├── demorb4_img04.gif │ │ ├── demosm1.html │ │ ├── demosm1_img02.gif │ │ ├── demosm1_img05.gif │ │ ├── demosm2.html │ │ ├── demosm2_img02.gif │ │ ├── demosm2_img04.gif │ │ └── demosm2_img05.gif │ ├── mydistf.m │ ├── mydnif.m │ ├── mydpf.m │ ├── mydtf.m │ ├── mydwf.m │ ├── mynif.m │ ├── mypf.m │ ├── mytf.m │ ├── mytopf.m │ ├── mywbif.m │ ├── mywblf.m │ ├── mywf.m │ ├── nnd.m │ ├── nnd10eeg.m │ ├── nnd10lc.m │ ├── nnd10nc.m │ ├── nnd11bc.m │ ├── nnd11fa.m │ ├── nnd11gn.m │ ├── nnd11nf.m │ ├── nnd12cg.m │ ├── nnd12ls.m │ ├── nnd12m.m │ ├── nnd12mo.m │ ├── nnd12ms.m │ ├── nnd12sd1.m │ ├── nnd12sd2.m │ ├── nnd12vl.m │ ├── nnd13edr.m │ ├── nnd13gis.m │ ├── nnd13hd.m │ ├── nnd13is.m │ ├── nnd13os.m │ ├── nnd13uh.m │ ├── nnd14cc.m │ ├── nnd14cl.m │ ├── nnd14fm1.m │ ├── nnd14fm2.m │ ├── nnd14lv1.m │ ├── nnd14lv2.m │ ├── nnd15aw.m │ ├── nnd15gl1.m │ ├── nnd15gl2.m │ ├── nnd15li.m │ ├── nnd15sn.m │ ├── nnd16a1.m │ ├── nnd16al1.m │ ├── nnd16al2.m │ ├── nnd16os.m │ ├── nnd17ds.m │ ├── nnd18hn.m │ ├── nnd2n1.m │ ├── nnd2n2.m │ ├── nnd3hamc.m │ ├── nnd3hopc.m │ ├── nnd3pc.m │ ├── nnd4db.m │ ├── nnd4pr.m │ ├── nnd5gs.m │ ├── nnd5rb.m │ ├── nnd6eg.m │ ├── nnd6lt.m │ ├── nnd7sh.m │ ├── nnd8dd.m │ ├── nnd8qf.m │ ├── nnd8ts1.m │ ├── nnd8ts2.m │ ├── nnd9mc.m │ ├── nnd9nm.m │ ├── nnd9sd.m │ ├── nnd9sdq.m │ ├── nndadapt.m │ ├── nndalay1.m │ ├── nndalay2.m │ ├── nndao.m │ ├── nndhop.m │ ├── nndhopi.m │ ├── nndlay1.m │ ├── nndlay2.m │ ├── nndpend.m │ ├── nndshunt.m │ ├── nndtoc.m │ ├── nngenc.m │ ├── nnsample.m │ ├── nnsound.m │ ├── plinear.m │ ├── plotchar.m │ ├── pmodel.m │ ├── private │ │ ├── eegdata.mat │ │ ├── nnarrow.m │ │ ├── nnaxclik.m │ │ ├── nnbg.m │ │ ├── nnblack.m │ │ ├── nncallbk.m │ │ ├── nncentxt.m │ │ ├── nnchkfs.m │ │ ├── nncolor.m │ │ ├── nndbp1.mat │ │ ├── nndbp2.mat │ │ ├── nndbp3.mat │ │ ├── nndbpm.m │ │ ├── nndemof.m │ │ ├── nndemof2.m │ │ ├── nndfgflg.m │ │ ├── nndicon.m │ │ ├── nndkblue.m │ │ ├── nndkgray.m │ │ ├── nndrawax.m │ │ ├── nndrwcir.m │ │ ├── nndrwlin.m │ │ ├── nndrwrec.m │ │ ├── nndrwvec.m │ │ ├── nndsicon.m │ │ ├── nndsnd.m │ │ ├── nndtext.m │ │ ├── nnfexist.m │ │ ├── nnfgflag.m │ │ ├── nngetclk.m │ │ ├── nngraybx.m │ │ ├── nngrays.m │ │ ├── nngreen.m │ │ ├── nnicon.m │ │ ├── nnline.m │ │ ├── nnlmarq.m │ │ ├── nnltblue.m │ │ ├── nnltgray.m │ │ ├── nnltyell.m │ │ ├── nnmdgray.m │ │ ├── nnmdlin.m │ │ ├── nnmdlog.m │ │ ├── nnpause.m │ │ ├── nnpin.m │ │ ├── nnred.m │ │ ├── nnsettxt.m │ │ ├── nnsfo.m │ │ ├── nnshrink.m │ │ ├── nnstuded.m │ │ ├── nntexist.m │ │ ├── nntfnms.m │ │ ├── nntitlef.m │ │ ├── nntocf.m │ │ ├── nntxtchk.m │ │ ├── nnwhite.m │ │ └── nnyellow.m │ └── prprob.m ├── nnet │ ├── @network │ │ ├── adapt.m │ │ ├── disp.m │ │ ├── display.m │ │ ├── gensim.m │ │ ├── init.m │ │ ├── loadobj.m │ │ ├── network.m │ │ ├── private │ │ │ ├── active.m │ │ │ ├── boolstr.m │ │ │ ├── checkai.m │ │ │ ├── checkp.m │ │ │ ├── checkpi.m │ │ │ ├── checkt.m │ │ │ ├── formatai.m │ │ │ ├── formatp.m │ │ │ ├── formatpi.m │ │ │ ├── formatt.m │ │ │ ├── hasfield.m │ │ │ ├── isbias.m │ │ │ ├── isbool.m │ │ │ ├── isempmat.m │ │ │ ├── isinput.m │ │ │ ├── islayer.m │ │ │ ├── isnif.m │ │ │ ├── isoutput.m │ │ │ ├── isposint.m │ │ │ ├── istf.m │ │ │ └── isweight.m │ │ ├── revert.m │ │ ├── sim.m │ │ ├── subsasgn.m │ │ ├── subsref.m │ │ └── train.m │ ├── Contents.m │ ├── boxdist.m │ ├── combvec.m │ ├── compet.m │ ├── con2seq.m │ ├── concur.m │ ├── ddotprod.m │ ├── dhardlim.m │ ├── dhardlms.m │ ├── dist.m │ ├── dlogsig.m │ ├── dmae.m │ ├── dmse.m │ ├── dmsereg.m │ ├── dnetprod.m │ ├── dnetsum.m │ ├── dotprod.m │ ├── dposlin.m │ ├── dpurelin.m │ ├── dradbas.m │ ├── dsatlin.m │ ├── dsatlins.m │ ├── dsse.m │ ├── dtansig.m │ ├── dtribas.m │ ├── errsurf.m │ ├── gridtop.m │ ├── hardlim.m │ ├── hardlims.m │ ├── hextop.m │ ├── hintonw.m │ ├── hintonwb.m │ ├── ind2vec.m │ ├── info.xml │ ├── initcon.m │ ├── initlay.m │ ├── initnw.m │ ├── initwb.m │ ├── initzero.m │ ├── ja │ │ └── info.xml │ ├── learncon.m │ ├── learngd.m │ ├── learngdm.m │ ├── learnh.m │ ├── learnhd.m │ ├── learnis.m │ ├── learnk.m │ ├── learnlv1.m │ ├── learnlv2.m │ ├── learnos.m │ ├── learnp.m │ ├── learnpn.m │ ├── learnsom.m │ ├── learnwh.m │ ├── linkdist.m │ ├── logsig.m │ ├── mae.m │ ├── mandist.m │ ├── maxlinlr.m │ ├── midpoint.m │ ├── minmax.m │ ├── mse.m │ ├── msereg.m │ ├── negdist.m │ ├── netprod.m │ ├── netsum.m │ ├── neural.mdl │ ├── newc.m │ ├── newcf.m │ ├── newelm.m │ ├── newff.m │ ├── newfftd.m │ ├── newgrnn.m │ ├── newhop.m │ ├── newlin.m │ ├── newlind.m │ ├── newlvq.m │ ├── newp.m │ ├── newpnn.m │ ├── newrb.m │ ├── newrbe.m │ ├── newsom.m │ ├── nncopy.m │ ├── nnt2c.m │ ├── nnt2elm.m │ ├── nnt2ff.m │ ├── nnt2hop.m │ ├── nnt2lin.m │ ├── nnt2lvq.m │ ├── nnt2p.m │ ├── nnt2rb.m │ ├── nnt2som.m │ ├── nntool.m │ ├── normc.m │ ├── normprod.m │ ├── normr.m │ ├── plotbr.m │ ├── plotep.m │ ├── plotes.m │ ├── plotpc.m │ ├── plotperf.m │ ├── plotpv.m │ ├── plotsom.m │ ├── plotv.m │ ├── plotvec.m │ ├── pnormc.m │ ├── poslin.m │ ├── postmnmx.m │ ├── postreg.m │ ├── poststd.m │ ├── premnmx.m │ ├── prepca.m │ ├── prestd.m │ ├── purelin.m │ ├── quant.m │ ├── radbas.m │ ├── randnc.m │ ├── randnr.m │ ├── rands.m │ ├── randtop.m │ ├── satlin.m │ ├── satlins.m │ ├── seq2con.m │ ├── slblocks.m │ ├── softmax.m │ ├── srchbac.m │ ├── srchbre.m │ ├── srchcha.m │ ├── srchgol.m │ ├── srchhyb.m │ ├── sse.m │ ├── sumsqr.m │ ├── tansig.m │ ├── trainb.m │ ├── trainbfg.m │ ├── trainbr.m │ ├── trainc.m │ ├── traincgb.m │ ├── traincgf.m │ ├── traincgp.m │ ├── traingd.m │ ├── traingda.m │ ├── traingdm.m │ ├── traingdx.m │ ├── trainlm.m │ ├── trainoss.m │ ├── trainr.m │ ├── trainrp.m │ ├── trains.m │ ├── trainscg.m │ ├── tramnmx.m │ ├── trapca.m │ ├── trastd.m │ ├── tribas.m │ └── vec2ind.m ├── nnobsolete │ ├── adaptwb.m │ ├── adaptwh.m │ ├── alabel.m │ ├── appcs1.m │ ├── appcs1b.m │ ├── appcs1d.mat │ ├── appcs2.m │ ├── appcs2b.m │ ├── appcs2d.mat │ ├── appcs2d2.mat │ ├── applin3.m │ ├── applin4.m │ ├── assoclr.m │ ├── backprop.m │ ├── barerr.m │ ├── compnet.m │ ├── delaysig.m │ ├── deltalin.m │ ├── deltalog.m │ ├── deltatan.m │ ├── elman.m │ ├── hopfield.m │ ├── initc.m │ ├── initelm.m │ ├── initff.m │ ├── initlin.m │ ├── initlvq.m │ ├── initp.m │ ├── initsm.m │ ├── learnbp.m │ ├── learnbpm.m │ ├── learnlm.m │ ├── learnlvq.m │ ├── linnet.m │ ├── lvq.m │ ├── nbdist.m │ ├── nbgrid.m │ ├── nbman.m │ ├── nncpy.m │ ├── nncpyd.m │ ├── nncpyi.m │ ├── nndef.m │ ├── nnfmc.m │ ├── nnmaxr.m │ ├── nnminr.m │ ├── nnsumr.m │ ├── nwlog.m │ ├── nwtan.m │ ├── percept.m │ ├── pickic.m │ ├── ploterr.m │ ├── plotfa.m │ ├── plotlr.m │ ├── plotmap.m │ ├── plotsm.m │ ├── plottr.m │ ├── radbasis.m │ ├── selforg.m │ ├── simuc.m │ ├── simuelm.m │ ├── simuff.m │ ├── simuhop.m │ ├── simulin.m │ ├── simulvq.m │ ├── simup.m │ ├── simurb.m │ ├── simusm.m │ ├── solvehop.m │ ├── solvelin.m │ ├── solverb.m │ ├── solverbe.m │ ├── tbp1.m │ ├── tbp2.m │ ├── tbp3.m │ ├── tbpx1.m │ ├── tbpx2.m │ ├── tbpx3.m │ ├── tlm1.m │ ├── tlm2.m │ ├── tlm3.m │ ├── trainbp.m │ ├── trainbpa.m │ ├── trainbpm.m │ ├── trainbpx.m │ ├── traincold.m │ ├── trainelm.m │ ├── trainlvq.m │ ├── trainp.m │ ├── trainpn.m │ ├── trainsm.m │ ├── trainwb.m │ ├── trainwb1.m │ └── trainwh.m └── nnutils │ ├── addnntemppath.m │ ├── calca.m │ ├── calca1.m │ ├── calce.m │ ├── calce1.m │ ├── calcerr.m │ ├── calcgrad.m │ ├── calcgx.m │ ├── calcjejj.m │ ├── calcjx.m │ ├── calcpd.m │ ├── calcperf.m │ ├── cliptr.m │ ├── competsl.m │ ├── dnullpf.m │ ├── dnulltf.m │ ├── dnullwf.m │ ├── formgx.m │ ├── formx.m │ ├── genbpm.m │ ├── gensimm.m │ ├── gentraincm.m │ ├── gentrainrm.m │ ├── gentrainsm.m │ ├── getx.m │ ├── newnet.m │ ├── newnntempfile.m │ ├── newtr.m │ ├── nnetbhelp.m │ ├── nnguitools.m │ ├── nntesthelp.m │ ├── nntobsf.m │ ├── nntobsu.m │ ├── nntwarn.m │ ├── nullpf.m │ ├── pause2.m │ ├── private │ ├── nncell2string.m │ └── nnmat2string.m │ ├── setx.m │ ├── substring.m │ ├── trainb2.m │ ├── trainc2.m │ ├── traingd2.m │ ├── trainr2.m │ ├── trains2.m │ └── updatenet.m ├── purelin.m ├── rands.m ├── simuff.m ├── tansig.m ├── test_test_lm.m ├── tlm1.m ├── tlm2.m ├── tlm3.m └── trainlm.m /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # matlab-dadm 2 | MATLAB数据分析与挖掘实战 3 | -------------------------------------------------------------------------------- /ch02/code/batch_pic_process.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/code/batch_pic_process.m -------------------------------------------------------------------------------- /ch02/code/cust_plot.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/code/cust_plot.m -------------------------------------------------------------------------------- /ch02/code/database_example.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/code/database_example.m -------------------------------------------------------------------------------- /ch02/data/images/1_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/data/images/1_1.jpg -------------------------------------------------------------------------------- /ch02/data/images/1_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/data/images/1_2.jpg -------------------------------------------------------------------------------- /ch02/data/images/1_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/data/images/1_3.jpg -------------------------------------------------------------------------------- /ch02/data/images/1_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/data/images/1_4.jpg -------------------------------------------------------------------------------- /ch02/data/images/1_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/data/images/1_5.jpg -------------------------------------------------------------------------------- /ch02/data/time_series.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch02/data/time_series.xls -------------------------------------------------------------------------------- /ch03/code/correlation_analyze.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/code/correlation_analyze.m -------------------------------------------------------------------------------- /ch03/code/de_missing_abnormal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/code/de_missing_abnormal.m -------------------------------------------------------------------------------- /ch03/code/dish_pareto.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/code/dish_pareto.m -------------------------------------------------------------------------------- /ch03/code/missing_abnormal_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/code/missing_abnormal_check.m -------------------------------------------------------------------------------- /ch03/code/statistics_analyze.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/code/statistics_analyze.m -------------------------------------------------------------------------------- /ch03/data/catering_dish_profit.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/data/catering_dish_profit.xls -------------------------------------------------------------------------------- /ch03/data/catering_fish_congee.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/data/catering_fish_congee.xls -------------------------------------------------------------------------------- /ch03/data/catering_sale.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/data/catering_sale.xls -------------------------------------------------------------------------------- /ch03/data/catering_sale_all.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch03/data/catering_sale_all.xls -------------------------------------------------------------------------------- /ch04/code/abnormal_rules_1.m: -------------------------------------------------------------------------------- 1 | function [ flag ] = abnormal_rules_1( sale ) 2 | 3 | if sale >400 && sale <5000 || isnan(sale) 4 | flag=true; 5 | return ; 6 | end 7 | flag =false; 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /ch04/code/cust_subplot.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/cust_subplot.m -------------------------------------------------------------------------------- /ch04/code/data_discretization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/data_discretization.m -------------------------------------------------------------------------------- /ch04/code/data_normalization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/data_normalization.m -------------------------------------------------------------------------------- /ch04/code/de_abnormal.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/de_abnormal.m -------------------------------------------------------------------------------- /ch04/code/find_type.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/find_type.m -------------------------------------------------------------------------------- /ch04/code/lagrange_interp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/lagrange_interp.m -------------------------------------------------------------------------------- /ch04/code/lagrange_newton_interp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/lagrange_newton_interp.m -------------------------------------------------------------------------------- /ch04/code/line_rate_construct.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/line_rate_construct.m -------------------------------------------------------------------------------- /ch04/code/newton_interp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/newton_interp.m -------------------------------------------------------------------------------- /ch04/code/ployinterp_column.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/ployinterp_column.m -------------------------------------------------------------------------------- /ch04/code/principal_component_analyze.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/principal_component_analyze.m -------------------------------------------------------------------------------- /ch04/code/wave_analyze.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/code/wave_analyze.m -------------------------------------------------------------------------------- /ch04/data/catering_sale.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/data/catering_sale.xls -------------------------------------------------------------------------------- /ch04/data/discretization_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/data/discretization_data.xls -------------------------------------------------------------------------------- /ch04/data/electricity_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/data/electricity_data.xls -------------------------------------------------------------------------------- /ch04/data/normalization_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/data/normalization_data.xls -------------------------------------------------------------------------------- /ch04/data/principal_component.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch04/data/principal_component.xls -------------------------------------------------------------------------------- /ch05/code/ID3_decision_tree.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/ID3_decision_tree.m -------------------------------------------------------------------------------- /ch05/code/arima_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/arima_test.m -------------------------------------------------------------------------------- /ch05/code/bp_neural_network.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/bp_neural_network.m -------------------------------------------------------------------------------- /ch05/code/bp_preprocess.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/bp_preprocess.m -------------------------------------------------------------------------------- /ch05/code/cal_apriori.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/cal_apriori.m -------------------------------------------------------------------------------- /ch05/code/discrete_point_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/discrete_point_test.m -------------------------------------------------------------------------------- /ch05/code/findRules.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/findRules.m -------------------------------------------------------------------------------- /ch05/code/id3.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/id3.m -------------------------------------------------------------------------------- /ch05/code/id3_preprocess.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/id3_preprocess.m -------------------------------------------------------------------------------- /ch05/code/k_means.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/k_means.m -------------------------------------------------------------------------------- /ch05/code/logistic_regression.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/logistic_regression.m -------------------------------------------------------------------------------- /ch05/code/print_tree.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/print_tree.m -------------------------------------------------------------------------------- /ch05/code/queue_curr_size.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/queue_curr_size.m -------------------------------------------------------------------------------- /ch05/code/queue_pop.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/queue_pop.m -------------------------------------------------------------------------------- /ch05/code/queue_push.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/queue_push.m -------------------------------------------------------------------------------- /ch05/code/trans2matrix.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/trans2matrix.m -------------------------------------------------------------------------------- /ch05/code/tree_plot.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/code/tree_plot.m -------------------------------------------------------------------------------- /ch05/data/arima_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/data/arima_data.xls -------------------------------------------------------------------------------- /ch05/data/bankloan.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/data/bankloan.xls -------------------------------------------------------------------------------- /ch05/data/consumption_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/data/consumption_data.xls -------------------------------------------------------------------------------- /ch05/data/menu_orders.txt: -------------------------------------------------------------------------------- 1 | a,c,e 2 | b,d 3 | b,c 4 | a,b,c,d 5 | a,b 6 | b,c 7 | a,b 8 | a,b,c,e 9 | a,b,c 10 | a,c,e -------------------------------------------------------------------------------- /ch05/data/sales_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch05/data/sales_data.xls -------------------------------------------------------------------------------- /ch06/code/Lagrange_interpolation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/Lagrange_interpolation.m -------------------------------------------------------------------------------- /ch06/code/construct_dt_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/construct_dt_model.m -------------------------------------------------------------------------------- /ch06/code/construct_lm_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/construct_lm_model.m -------------------------------------------------------------------------------- /ch06/code/ployinterp_column.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/ployinterp_column.m -------------------------------------------------------------------------------- /ch06/code/polyinterp.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/polyinterp.m -------------------------------------------------------------------------------- /ch06/code/split2train_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/split2train_test.m -------------------------------------------------------------------------------- /ch06/code/split_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/split_data.m -------------------------------------------------------------------------------- /ch06/code/test_lm_dt_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/code/test_lm_dt_model.m -------------------------------------------------------------------------------- /ch06/data/missing_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/data/missing_data.xls -------------------------------------------------------------------------------- /ch06/data/model.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/data/model.xls -------------------------------------------------------------------------------- /ch06/data/test_model.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/data/test_model.xls -------------------------------------------------------------------------------- /ch06/data/train_model.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/data/train_model.xls -------------------------------------------------------------------------------- /ch06/data/拓展思考样本数据.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/data/拓展思考样本数据.xls -------------------------------------------------------------------------------- /ch06/data/窃漏电构建模型输入数据.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/data/窃漏电构建模型输入数据.xls -------------------------------------------------------------------------------- /ch06/tmp/lm_train_output_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/tmp/lm_train_output_data.xls -------------------------------------------------------------------------------- /ch06/tmp/missing_data_processed.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/tmp/missing_data_processed.xls -------------------------------------------------------------------------------- /ch06/tmp/net.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/tmp/net.mat -------------------------------------------------------------------------------- /ch06/tmp/test_model.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/tmp/test_model.xls -------------------------------------------------------------------------------- /ch06/tmp/train_model.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch06/tmp/train_model.xls -------------------------------------------------------------------------------- /ch07/code/data_clean.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/data_clean.m -------------------------------------------------------------------------------- /ch07/code/data_explore.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/data_explore.m -------------------------------------------------------------------------------- /ch07/code/filter_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/filter_data.m -------------------------------------------------------------------------------- /ch07/code/find_empty.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/find_empty.m -------------------------------------------------------------------------------- /ch07/code/kmeans_cluster.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/kmeans_cluster.m -------------------------------------------------------------------------------- /ch07/code/log_add.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/log_add.m -------------------------------------------------------------------------------- /ch07/code/zscore_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/code/zscore_data.m -------------------------------------------------------------------------------- /ch07/data/air_data.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/data/air_data.csv -------------------------------------------------------------------------------- /ch07/data/zscoredata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/data/zscoredata.xls -------------------------------------------------------------------------------- /ch07/data/zscoreddata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch07/data/zscoreddata.xls -------------------------------------------------------------------------------- /ch08/code/apriori_rules.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch08/code/apriori_rules.m -------------------------------------------------------------------------------- /ch08/code/discretization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch08/code/discretization.m -------------------------------------------------------------------------------- /ch08/code/filter_rules.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch08/code/filter_rules.m -------------------------------------------------------------------------------- /ch08/code/findRules.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch08/code/findRules.m -------------------------------------------------------------------------------- /ch08/code/trans2matrix.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch08/code/trans2matrix.m -------------------------------------------------------------------------------- /ch08/data/data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch08/data/data.xls -------------------------------------------------------------------------------- /ch09/code/color_moment_extract.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/code/color_moment_extract.m -------------------------------------------------------------------------------- /ch09/code/construct_lm_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/code/construct_lm_model.m -------------------------------------------------------------------------------- /ch09/code/picture_slicer.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/code/picture_slicer.m -------------------------------------------------------------------------------- /ch09/code/split2train_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/code/split2train_test.m -------------------------------------------------------------------------------- /ch09/code/split_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/code/split_data.m -------------------------------------------------------------------------------- /ch09/code/test_lm_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/code/test_lm_model.m -------------------------------------------------------------------------------- /ch09/data/1_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/data/1_1.jpg -------------------------------------------------------------------------------- /ch09/data/1_1_processed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/data/1_1_processed.jpg -------------------------------------------------------------------------------- /ch09/data/moment.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/data/moment.xls -------------------------------------------------------------------------------- /ch09/data/test_moment.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/data/test_moment.xls -------------------------------------------------------------------------------- /ch09/data/train_moment.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch09/data/train_moment.xls -------------------------------------------------------------------------------- /ch10/code/cust_ksdensity.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/cust_ksdensity.m -------------------------------------------------------------------------------- /ch10/code/extract_visit_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/extract_visit_data.m -------------------------------------------------------------------------------- /ch10/code/findRules.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/findRules.m -------------------------------------------------------------------------------- /ch10/code/preprocess_apriori.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/preprocess_apriori.m -------------------------------------------------------------------------------- /ch10/code/test.m: -------------------------------------------------------------------------------- 1 | k=3; 2 | out = 'tmp.xls'; 3 | [num,txt,raw] = xlsread('cluster.csv'); 4 | data = num(:,2:end-1); 5 | data_ = zscore(data); 6 | 7 | [idx,c]=kmeans(data_,k); 8 | raw_=[raw,['newG';num2cell(idx)]]; 9 | xlswrite(out,raw_); 10 | disp('done'); -------------------------------------------------------------------------------- /ch10/code/test_apriori.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/test_apriori.m -------------------------------------------------------------------------------- /ch10/code/test_kmeans.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/test_kmeans.m -------------------------------------------------------------------------------- /ch10/code/trans2matrix.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/trans2matrix.m -------------------------------------------------------------------------------- /ch10/code/z_score_cluster_data.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/code/z_score_cluster_data.m -------------------------------------------------------------------------------- /ch10/data/cluster_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/data/cluster_data.xls -------------------------------------------------------------------------------- /ch10/data/raw_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/data/raw_data.xls -------------------------------------------------------------------------------- /ch10/data/visit_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch10/data/visit_data.xls -------------------------------------------------------------------------------- /ch11/code/arima_model_check.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/code/arima_model_check.m -------------------------------------------------------------------------------- /ch11/code/attribute_transform.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/code/attribute_transform.m -------------------------------------------------------------------------------- /ch11/code/cal_errors.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/code/cal_errors.m -------------------------------------------------------------------------------- /ch11/code/find_optimal_pq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/code/find_optimal_pq.m -------------------------------------------------------------------------------- /ch11/code/stationarity_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/code/stationarity_test.m -------------------------------------------------------------------------------- /ch11/code/whitenoise_test.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/code/whitenoise_test.m -------------------------------------------------------------------------------- /ch11/data/discdata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/data/discdata.xls -------------------------------------------------------------------------------- /ch11/data/discdata_processed.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/data/discdata_processed.xls -------------------------------------------------------------------------------- /ch11/data/predictdata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch11/data/predictdata.xls -------------------------------------------------------------------------------- /ch12/code/cal_correlation.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/code/cal_correlation.m -------------------------------------------------------------------------------- /ch12/code/cal_weight_consistency_rate.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/code/cal_weight_consistency_rate.m -------------------------------------------------------------------------------- /ch12/data/addedwords_11.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/addedwords_11.xls -------------------------------------------------------------------------------- /ch12/data/address_4.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/address_4.xls -------------------------------------------------------------------------------- /ch12/data/identity_5.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/identity_5.xls -------------------------------------------------------------------------------- /ch12/data/name_2.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/name_2.xls -------------------------------------------------------------------------------- /ch12/data/paired_comparision.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/paired_comparision.xls -------------------------------------------------------------------------------- /ch12/data/phone_6.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/phone_6.xls -------------------------------------------------------------------------------- /ch12/data/qq_8.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/qq_8.xls -------------------------------------------------------------------------------- /ch12/data/score.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/score.xls -------------------------------------------------------------------------------- /ch12/data/sex_3.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/sex_3.xls -------------------------------------------------------------------------------- /ch12/data/sum_words.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/sum_words.xls -------------------------------------------------------------------------------- /ch12/data/user_information.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch12/data/user_information.xls -------------------------------------------------------------------------------- /ch13/code/divide_event.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/code/divide_event.m -------------------------------------------------------------------------------- /ch13/code/divide_event_for_optimization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/code/divide_event_for_optimization.m -------------------------------------------------------------------------------- /ch13/code/test_neural_network.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/code/test_neural_network.m -------------------------------------------------------------------------------- /ch13/code/threshold_optimization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/code/threshold_optimization.m -------------------------------------------------------------------------------- /ch13/code/train_neural_network.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/code/train_neural_network.m -------------------------------------------------------------------------------- /ch13/code/train_neural_network_bak.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/code/train_neural_network_bak.m -------------------------------------------------------------------------------- /ch13/data/neural_network_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/data/neural_network_data.xls -------------------------------------------------------------------------------- /ch13/data/original_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/data/original_data.xls -------------------------------------------------------------------------------- /ch13/data/test_neural_network_data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/data/test_neural_network_data.xls -------------------------------------------------------------------------------- /ch13/data/water_heater.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch13/data/water_heater.xls -------------------------------------------------------------------------------- /ch14/code/hierarchical_clustering.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/code/hierarchical_clustering.m -------------------------------------------------------------------------------- /ch14/code/hierarchical_clustering_pic.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/code/hierarchical_clustering_pic.m -------------------------------------------------------------------------------- /ch14/code/plotrows.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/code/plotrows.m -------------------------------------------------------------------------------- /ch14/code/standardization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/code/standardization.m -------------------------------------------------------------------------------- /ch14/code/subplotrows.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/code/subplotrows.m -------------------------------------------------------------------------------- /ch14/data/business_circle.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/data/business_circle.xls -------------------------------------------------------------------------------- /ch14/data/standardized.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch14/data/standardized.xls -------------------------------------------------------------------------------- /ch15/code/attr_state_count.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/attr_state_count.m -------------------------------------------------------------------------------- /ch15/code/bar_line_plot.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/bar_line_plot.m -------------------------------------------------------------------------------- /ch15/code/constructChildren.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/constructChildren.m -------------------------------------------------------------------------------- /ch15/code/data_exploration.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/data_exploration.m -------------------------------------------------------------------------------- /ch15/code/evaluateAttr.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/evaluateAttr.m -------------------------------------------------------------------------------- /ch15/code/hotspot.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/hotspot.m -------------------------------------------------------------------------------- /ch15/code/hs_preprocess.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/hs_preprocess.m -------------------------------------------------------------------------------- /ch15/code/m_rules_containkey.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/m_rules_containkey.m -------------------------------------------------------------------------------- /ch15/code/node_2_string.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/node_2_string.m -------------------------------------------------------------------------------- /ch15/code/print_hsnode.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/print_hsnode.m -------------------------------------------------------------------------------- /ch15/code/queue_push.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/queue_push.m -------------------------------------------------------------------------------- /ch15/code/queue_sort.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/queue_sort.m -------------------------------------------------------------------------------- /ch15/code/test_hotspot_bird.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/code/test_hotspot_bird.m -------------------------------------------------------------------------------- /ch15/data/defectdata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/data/defectdata.xls -------------------------------------------------------------------------------- /ch15/data/hotspotdata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/data/hotspotdata.xls -------------------------------------------------------------------------------- /ch15/data/weatherdata.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch15/data/weatherdata.xls -------------------------------------------------------------------------------- /ch16/java_code/lm_net_classify_class.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/java_code/lm_net_classify_class.java -------------------------------------------------------------------------------- /ch16/matlab_code/chgicon.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/chgicon.m -------------------------------------------------------------------------------- /ch16/matlab_code/deltalin.m: -------------------------------------------------------------------------------- 1 | function d = deltalin(a,d,w) 2 | %DELTALIN Delta function for PURELIN neurons. 3 | % 4 | % This function is obselete. 5 | % Use DPURELIN to calculates PURELIN derivatives. 6 | 7 | nntobsf('deltalin','Use DPURELIN to calculates PURELIN derivatives.') 8 | 9 | % 10 | % DELATLIN(A) 11 | % A - S1xQ matrix of output vectors. 12 | % Returns the S1xQ matrix of derivatives of the output vectors 13 | % with respect to the net input of the PURELIN transfer function. 14 | % 15 | % DELTALIN(A,E) 16 | % E - S1xQ matrix of associated errors 17 | % Returns an S1xQ matrix of derivatives of error for an output layer. 18 | % 19 | % DELTALIN(A,D,W) 20 | % D - S2xQ matrix of next layer delta vectors 21 | % W - S2xS1 weight matrix between layers. 22 | % Returns an S1xQ matrix of derivatives of error for a hidden layer. 23 | % 24 | % See also NNTRANS, BACKPROP, PURELIN. 25 | 26 | % Mark Beale, 1-31-92 27 | % Revised 12-15-93, MB 28 | % Copyright 1992-2002 The MathWorks, Inc. 29 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:45 $ 30 | 31 | if nargin == 1 32 | d = ones(size(a)); 33 | elseif nargin == 2 34 | d = d; 35 | else 36 | d = w'*d; 37 | end 38 | -------------------------------------------------------------------------------- /ch16/matlab_code/deltatan.m: -------------------------------------------------------------------------------- 1 | function d = deltatan(a,d,w) 2 | %DELTATAN Delta function for TANSIG neurons. 3 | % 4 | % This function is obselete. 5 | % Use DTANSIG to calculates TANSIG derivatives. 6 | 7 | nntobsf('deltatan','Use DTANSIG to calculates TANSIG derivatives.') 8 | 9 | % 10 | % DELTATAN(A,E) 11 | % A - S1xQ matrix of output vectors 12 | % E - S1xQ matrix of associated errors 13 | % Returns an SxQ matrix of output layer derivatives. 14 | % 15 | % DELTATAN(A,D,W) 16 | % D - S2xQ matrix of next layer delta vectors 17 | % W - S2xS1 weight matrix between layers. 18 | % Returns an SxQ matrix of hidden layer derivatives. 19 | % 20 | % DELTATAN(A) 21 | % Returns derivatives of outputs A (not error) for TRAINLM. 22 | % 23 | % See also NNTRANS, BACKPROP, TANSIG, DELTALOG, DELTALIN. 24 | 25 | % Mark Beale, 1-31-92 26 | % Revised 12-15-93, MB 27 | % Copyright 1992-2002 The MathWorks, Inc. 28 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:47 $ 29 | 30 | if nargin < 1,error('Not enough input arguments'),end 31 | 32 | if nargin == 1 33 | d = 1-(a.*a); 34 | elseif nargin == 2 35 | d = (1-(a.*a)).*d; 36 | else 37 | d = (1-(a.*a)).*(w'*d); 38 | end 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/dlogsig.m: -------------------------------------------------------------------------------- 1 | function d=dlogsig(n,a) 2 | %DLOGSIG Log sigmoid transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dlogsig(N,A) 7 | % 8 | % Description 9 | % 10 | % DLOGSIG is the derivative function for LOGSIG. 11 | % 12 | % DLOGSIG(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 TANSIG 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with LOGSIG and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = logsig(N) 28 | % dA_dN = dlogsig(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of LOGSIG is calculated as follows: 33 | % 34 | % d = a * (1 - a) 35 | % 36 | % See also LOGSIG, TANSIG, DTANSIG. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = a.*(1-a); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/dpurelin.m: -------------------------------------------------------------------------------- 1 | function d=dpurelin(n,a) 2 | %DPURELIN Linear transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dpurelin(N,A) 7 | % 8 | % Description 9 | % 10 | % DPURELIN is the derivative function for LOGSIG. 11 | % 12 | % DPURELIN(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 PURELIN 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with PURELIN and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = purelin(N) 28 | % dA_dN = dpurelin(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of PURELIN is calculated as follows: 33 | % 34 | % D(i,q) = 1 35 | % 36 | % See also PURELIN. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = ones(size(n)); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/dtansig.m: -------------------------------------------------------------------------------- 1 | function d=dtansig(n,a) 2 | %DTANSIG Hyperbolic tangent sigmoid transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dtansig(N,A) 7 | % 8 | % Description 9 | % 10 | % DTANSIG is the derivative function for TANSIG. 11 | % 12 | % DTANSIG(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 TANSIG 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with TANSIG and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = tansig(N) 28 | % dA_dN = dtansig(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of TANSIG is calculated as follows: 33 | % 34 | % d = 1-a^2 35 | % 36 | % See also TANSIG, LOGSIG, DLOGSIG. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = 1-(a.*a); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/learnlm.m: -------------------------------------------------------------------------------- 1 | function j = learnlm(p,d) 2 | %LEARNLM Levenberg-Marquardt learning rule. 3 | % 4 | % This function is obselete. 5 | % Use NNT2FF and TRAIN to update and train your network. 6 | 7 | nntobsf('learnlm','Use NNT2FF and TRAIN to update and train your network.') 8 | 9 | % LEARNLM(P,D) 10 | % P - RxQ matrix of input (column) vectors. 11 | % D - SxQ matrix of delta (column) vectors. 12 | % Returns: 13 | % Partial jacobian matrix. 14 | % 15 | % See also NNLEARN, BACKPROP, INITFF, SIMFF, TRAINLM. 16 | 17 | % Mark Beale, 12-15-93 18 | % Copyright 1992-2002 The MathWorks, Inc. 19 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:55 $ 20 | 21 | if nargin < 2, error('Wrong number of arguments.'),end 22 | 23 | [R,Q]=size(p); 24 | [S,Q]=size(d); 25 | j = nncpy(d',R) .* nncpyi(p',S); 26 | -------------------------------------------------------------------------------- /ch16/matlab_code/lmNetClassify.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/lmNetClassify.m -------------------------------------------------------------------------------- /ch16/matlab_code/lmNetPredict.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/lmNetPredict.m -------------------------------------------------------------------------------- /ch16/matlab_code/lmNetStructure.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/lmNetStructure.m -------------------------------------------------------------------------------- /ch16/matlab_code/lmNetTest.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/lmNetTest.m -------------------------------------------------------------------------------- /ch16/matlab_code/lmNetTrain.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/lmNetTrain.m -------------------------------------------------------------------------------- /ch16/matlab_code/lm_bp.m: -------------------------------------------------------------------------------- 1 | function[ppre] = lm_bp() 2 | p = [-1 -1 2 2;0 5 0 5]; 3 | t = [-1 -1 1 1]; 4 | net = newff(p,t,3,{},'trainlm'); 5 | net.trainParam.show = 50; 6 | net.trainParam.lr = 0.05; 7 | net.trainParam.mc = 0.9; 8 | net.trainParam.epochs = 1000; 9 | net.trainParam.goal = 1e-3; 10 | net.trainParam.showWindow = false; 11 | net = init(net); 12 | 13 | net = train(net,p,t); 14 | y = sim(net,p); 15 | ppre = y 16 | 17 | end 18 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/ball1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/ball1.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/cstr1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/cstr1.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/cstr2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/cstr2.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/cstr3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/cstr3.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/dnetinv.m: -------------------------------------------------------------------------------- 1 | function d=dnetinv(n,a) 2 | %DNETINV Inverse transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dnetinv(N,A) 7 | % 8 | % Description 9 | % 10 | % DNETINV is the derivative function for NETINV. 11 | % 12 | % DNETINV(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 NETINV 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with NETINV and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = netinv(N) 28 | % dA_dN = dnetinv(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of NETINV is calculated as follows: 33 | % 34 | % D(i,q) = -1/n^2 35 | % 36 | % See also NETINV. 37 | 38 | % Orlando De Jesus, Martin Hagan, 8-8-99 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.4 $ $Date: 2002/03/25 16:55:19 $ 41 | 42 | d = -1./(n.^2); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/nncontrolutil.m: -------------------------------------------------------------------------------- 1 | function varargout=nncontrolutil(command,varargin) 2 | %NNCONTROLUTIL Execute intermediate calls to private function under Simulink for NNcontrol toolbox. 3 | % 4 | % Synopsis 5 | % 6 | % varargout=nncontrolutil(command,varargin) 7 | % 8 | % command = Function called. 9 | % varargin = All the input parameters for the function in command. 10 | % 11 | % varargout = All the output parameters for the function in command. 12 | % 13 | 14 | % Orlando De Jesus, Martin Hagan, 2-27-00 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.4 $ $Date: 2002/03/25 16:55:20 $ 17 | 18 | n_par=nargout; 19 | if n_par==0 20 | feval(command,varargin{:}); 21 | else 22 | varargout=cell(1,n_par); 23 | [varargout{:}]=feval(command,varargin{:}); 24 | end 25 | 26 | command=command; 27 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/robot1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/robot1.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/robot1norm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/robot1norm.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/robot1ref.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/robot1ref.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/robot2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/robot2.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/robot2norm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/robot2norm.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nncontrol/robot3norm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nncontrol/robot3norm.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/choles_all.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/choles_all.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/demohop4.m: -------------------------------------------------------------------------------- 1 | %% Spurious Stable Points 2 | % A Hopfield network with five neurons is designed to have four stable 3 | % equilibria. However, unavoidably, it has other undesired equilibria. 4 | % 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.18 $ $Date: 2002/03/29 19:36:20 $ 7 | 8 | %% 9 | % We would like to obtain a Hopfield network that has the four stable points 10 | % defined by the two target (column) vectors in T. 11 | 12 | T = [+1 +1 -1 +1; ... 13 | -1 +1 +1 -1; ... 14 | -1 -1 -1 +1; ... 15 | +1 +1 +1 +1; ... 16 | -1 -1 +1 +1]; 17 | 18 | %% 19 | % The function NEWHOP creates Hopfield networks given the stable points T. 20 | 21 | net = newhop(T); 22 | 23 | %% 24 | % Here we define 4 random starting points and simulate the Hopfield network for 25 | % 50 steps. 26 | % 27 | % Some initial conditions will lead to desired stable points. Others will lead 28 | % to undesired stable points. 29 | 30 | P = {rands(5,4)}; 31 | [Y,Pf,Af] = sim(net,{4 50},{},P); 32 | Y{end} 33 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/democ1_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/democ1_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/democ1_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/democ1_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/democ1_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/democ1_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demogrn1_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demogrn1_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demogrn1_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demogrn1_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demogrn1_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demogrn1_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demogrn1_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demogrn1_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop1_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop1_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop1_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop1_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop1_img08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop1_img08.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop2_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop2_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop2_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop2_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop2_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop2_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop3_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop3_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop3_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop3_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop3_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop3_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demohop3_img08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demohop3_img08.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin1_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin1_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin1_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin1_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin2_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin2_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin2_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin2_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin2_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin2_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin4_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin4_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin4_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin4_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin4_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin4_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin5_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin5_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin5_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin5_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin5_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin5_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin5_img08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin5_img08.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin6_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin6_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin7_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin7_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin7_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin7_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin7_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin7_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin8_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin8_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolin8_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolin8_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolvq1_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolvq1_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolvq1_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolvq1_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demolvq1_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demolvq1_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop1_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop1_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop1_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop1_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop1_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop1_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop1_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop1_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop1_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop1_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop4_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop4_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop4_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop4_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop4_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop4_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop4_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop4_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop4_img08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop4_img08.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop4_img09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop4_img09.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop5_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop5_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop5_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop5_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop5_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop5_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop5_img07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop5_img07.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop5_img08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop5_img08.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop5_img09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop5_img09.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop6_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop6_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop6_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop6_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demop6_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demop6_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demopnn1_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demopnn1_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demopnn1_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demopnn1_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demopnn1_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demopnn1_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demopnn1_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demopnn1_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb1_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb1_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb1_img03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb1_img03.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb1_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb1_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb1_img06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb1_img06.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb3_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb3_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb3_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb3_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb4_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb4_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demorb4_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demorb4_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demosm1_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demosm1_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demosm1_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demosm1_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demosm2_img02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demosm2_img02.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demosm2_img04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demosm2_img04.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/html/demosm2_img05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/html/demosm2_img05.gif -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/mydistf.m: -------------------------------------------------------------------------------- 1 | function d = mydistf(pos) 2 | %MYDISTF Example custom distance function. 3 | % 4 | % Use this function as a template to write your own function. 5 | % 6 | % Syntax 7 | % 8 | % d = mydistf(pos) 9 | % pos - NxS matrix of S neuron position vectors. 10 | % d - SxS matrix of neuron distances. 11 | % 12 | % Example 13 | % 14 | % pos = gridtop(3,2); 15 | % d = mydistf(pos) 16 | % $Revision: 1.3 $ 17 | 18 | s = size(pos,2); 19 | for i=1:s 20 | for j=1:s 21 | 22 | % ** Replace the following line of code with your own 23 | % ** measure of distance. 24 | 25 | d(i,j) = norm(pos(:,i)-pos(:,j),1.5); 26 | 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/mydnif.m: -------------------------------------------------------------------------------- 1 | function d = mydnif(z,n) 2 | %MYDNIF Example custom net input derivative function of MYNIF. 3 | % 4 | % Use this function as a template to write your own function. 5 | % 6 | % Syntax 7 | % 8 | % dN_dZ = dtansig(Z,N) 9 | % Z - SxQ matrix of Q weighted input (column) vectors. 10 | % N - SxQ matrix of Q net input (column) vectors. 11 | % dN_dZ - SxQ derivative dN/dZ. 12 | % 13 | % Example 14 | % 15 | % z1 = rand(4,5); 16 | % z2 = rand(4,5); 17 | % z3 = rand(4,5); 18 | % n = mynif(z1,z2,z3) 19 | % dn_dz1 = mydnif(z1,n) 20 | % dn_dz2 = mydnif(z2,n) 21 | % dn_dz3 = mydnif(z3,n) 22 | % $Revision: 1.3 $ 23 | 24 | % ** Replace the following calculation with your 25 | % ** derivative calculation. 26 | 27 | d = n.^2 .* z.^2; 28 | 29 | % ** Note that you have both the net input Z in question 30 | % ** and output N available to calculate the derivative. 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/mydtf.m: -------------------------------------------------------------------------------- 1 | function d = mydtf(n,a) 2 | %MYDTF Example custom transfer derivative function of MYTF. 3 | % 4 | % Use this function as a template to write your own function. 5 | % 6 | % Syntax 7 | % 8 | % dA_dN = mydtf(N,A) 9 | % N - SxQ matrix of Q net input (column) vectors. 10 | % A - SxQ matrix of Q output (column) vectors. 11 | % dA_dN - SxQ derivative dA/dN. 12 | % 13 | % Example 14 | % 15 | % n = -5:.1:5; 16 | % a = mytf(n); 17 | % da_dn = mydtf(n,a); 18 | % subplot(2,1,1), plot(n,a) 19 | % subplot(2,1,2), plot(n,da_dn) 20 | % $Revision: 1.2 $ 21 | 22 | % ** Replace the following calculation with your 23 | % ** derivative calculation. 24 | 25 | d = -8*n.^7.*a.^2; 26 | 27 | % ** Note that you have both the transfer functions input N and 28 | % ** output A available, which can often allow a more efficient 29 | % ** calculation of the derivative than with just N. 30 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/mywbif.m: -------------------------------------------------------------------------------- 1 | function w = mywbif(s,pr) 2 | %MYWBIF Example custom weight and bias initialization function. 3 | % 4 | % Use this function as a template to write your own function. 5 | % 6 | % Syntax 7 | % 8 | % W = rands(S,PR) 9 | % S - number of neurons. 10 | % PR - Rx2 matrix of R input ranges. 11 | % W - SxR weight matrix. 12 | % 13 | % b = rands(S) 14 | % S - number of neurons. 15 | % b - Sx1 bias vector. 16 | % 17 | % Example 18 | % 19 | % W = mywbif(4,[0 1; -2 2]) 20 | % b = mywbif(4,[1 1]) 21 | % $Revision: 1.2 $ 22 | 23 | if nargin < 1, error('Not enough input arguments'), end 24 | 25 | if nargin == 1 26 | w = rand(s,1)*0.2; % <-- Replace with your own initial bias vector 27 | else 28 | r = size(pr,1); % <-- Replace with your own initial weight matrix 29 | w = rand(s,r)*0.1; 30 | end 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndadapt.m: -------------------------------------------------------------------------------- 1 | function wprime = nndadapt(t,w) 2 | %NNDADAPT Calculates the derivative for adaptive weights of the Grossberg network 3 | % 4 | % NNDADAPT(t,w2) 5 | % t - Current time 6 | % w - Weights (w(1)=w1,1, w(2)=w12, w(3)=w21, w(4)=w22) 7 | % Returns dw. 8 | 9 | % $Revision: 1.6 $ 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | global n1_1; 16 | global n1_2; 17 | global lr; 18 | 19 | if (rem(fix(t/0.2),2)==0), 20 | n1 = n1_1; 21 | n2 = [1; 0]; 22 | else 23 | n1 = n1_2; 24 | n2 = [0; 1]; 25 | end 26 | 27 | w = reshape(w,2,2); 28 | 29 | if lr == 1 30 | wprime = (4*n2*ones(1,2)).*(ones(2,1)*n1'-w); 31 | else 32 | wprime = 4*n2*n1' - 2*w; 33 | end 34 | 35 | wprime = reshape(wprime,4,1); 36 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndalay1.m: -------------------------------------------------------------------------------- 1 | function yprime = nndalay1(t,y) 2 | %NNDALAY1 Calculates the derivative for layer 1 of the Grossberg network 3 | % 4 | % NNDALAY1(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy. 8 | 9 | 10 | % $Revision: 1.6 $ 11 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 12 | % First Version, 8-31-95. 13 | 14 | %================================================================== 15 | 16 | global p; 17 | global bp; 18 | global bn; 19 | global W21; 20 | 21 | e= 0.1; 22 | j = 2; 23 | 24 | yprime = [-y(1) + (bp - y(1))*(p(1)+W21(1,j)) - (y(1) + bn); 25 | -y(2) + (bp - y(2))*(p(2)+W21(2,j)) - (y(2) + bn) ]/e; 26 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndalay2.m: -------------------------------------------------------------------------------- 1 | function yprime = nndalay2(t,y) 2 | %NNDALAY2 Calculates the derivative for layer 2 of the Grossberg network 3 | % 4 | % NNDALAY2(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy. 8 | 9 | % $Revision: 1.6 $ 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | global p; 16 | global bp; 17 | global bn; 18 | global A; 19 | 20 | w1 = [0.5 0.5]; 21 | w2 = [1 0]; 22 | e = 0.1; 23 | 24 | i1 = w1*p; 25 | i2 = w2*p; 26 | 27 | a = (A*y.^2) .* (y>0); 28 | 29 | yprime = [-y(1) + (bp - y(1))*(a(1)+i1) - (y(1) + bn)*a(2); 30 | -y(2) + (bp - y(2))*(a(2)+i2) - (y(2) + bn)*a(1)] /e; 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndao.m: -------------------------------------------------------------------------------- 1 | function yprime = nndao(t,y) 2 | %NNDAO Calculates derivative for orienting subsystem of ART network 3 | % 4 | % NNDAO(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy. 8 | 9 | % $Revision: 1.7 $ 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | global p; 16 | global a; 17 | global A; 18 | global B; 19 | 20 | bp = 1; 21 | bn = 1; 22 | e = 0.1; 23 | 24 | yprime = (-y + (bp - y)*A*(p(1)+p(2)) - (y + bn)*B*(a(1)+a(2)) )/e; 25 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndhop.m: -------------------------------------------------------------------------------- 1 | function yprime = nndhop(t,y) 2 | %NNDHOP Calculates the derivative for Hopfield network 3 | % 4 | % NNDHOP(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy. 8 | 9 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 10 | % $Revision: 1.6 $ 11 | 12 | global lambda; 13 | global W; 14 | global b; 15 | 16 | a = 2/pi*atan(lambda*pi*y*0.5); 17 | yprime = -y+W*a+b; 18 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndhopi.m: -------------------------------------------------------------------------------- 1 | function yprime = nndhopi(t,y) 2 | %NNDHOPI Calculates the derivative for sample Hopfield network 3 | % 4 | % NNDHOPI(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy 8 | 9 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 10 | % $Revision: 1.5 $ 11 | 12 | global W; 13 | global b; 14 | 15 | % Assuming infinite Lambda: 16 | 17 | yprime = 0.5*W*y + b; 18 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndlay1.m: -------------------------------------------------------------------------------- 1 | function yprime = nndlay1(t,y) 2 | %NNDLAY1 Calculates the derivative for layer 1 of the Grossberg network 3 | % 4 | % NNDLAY1(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy. 8 | 9 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 10 | % $Revision: 1.6 $ 11 | 12 | global p; 13 | global bp; 14 | global bn; 15 | global e; 16 | 17 | yprime = [(-y(1) + (bp - y(1))*p(1) - (y(1) + bn)*p(2)); 18 | (-y(2) + (bp - y(2))*p(2) - (y(2) + bn)*p(1))] / e; 19 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndlay2.m: -------------------------------------------------------------------------------- 1 | function yprime = nndlay2(t,y) 2 | %NNDLAY2 Calculates the derivative for layer 2 of the Grossberg network 3 | % 4 | % NNDLAY2(t,y) 5 | % t - Current time 6 | % y - Current output 7 | % Returns dy. 8 | 9 | % $Revision: 1.6 $ 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | global p; 16 | global tf; 17 | global W2; 18 | 19 | yprime = zeros(2,1); 20 | bp = 1; 21 | bn = 0; 22 | e = 0.1; 23 | 24 | i1 = W2(1,:)*p; 25 | i2 = W2(2,:)*p; 26 | 27 | if tf == 1 28 | a = y; 29 | elseif tf == 2 30 | a = 10*(y.^2)/(1+y.^2); 31 | elseif tf == 3 32 | a = 10*(y.^2); 33 | else 34 | a = 1-exp(-y); 35 | end 36 | 37 | yprime(1) = (-y(1) + (bp - y(1))*(a(1)+i1) - (y(1) + bn)*a(2))/e; 38 | yprime(2) = (-y(2) + (bp - y(2))*(a(2)+i2) - (y(2) + bn)*a(1))/e; 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndpend.m: -------------------------------------------------------------------------------- 1 | function yprime = nndpend(t,y) 2 | %NNDPEND Dynamical model of a pendulum. 3 | % 4 | % NNDPEND(T,Y) 5 | % T - Time 6 | % Y - State = [angle; angular velocity] 7 | % Returns Derivative of state vector. 8 | 9 | % $Revision: 1.6 $ 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | yprime = zeros(2,1); 16 | 17 | yprime(1) = y(2); 18 | yprime(2) = -sin(y(1)) - 0.2*y(2); 19 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/nndshunt.m: -------------------------------------------------------------------------------- 1 | function yprime = nndshunt(t,y) 2 | %NNDSHUNT Calculates the derivative for a shunting network 3 | % 4 | % NNDSHUNT(T,Y) 5 | % T - Time 6 | % Y - State 7 | % Returns dY. 8 | 9 | % $Revision: 1.6 $ 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | global pp; 16 | global pn; 17 | global bp; 18 | global bn; 19 | global e; 20 | 21 | yprime = (-y + (bp - y)*pp - (y + bn)*pn)/e; 22 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/plinear.m: -------------------------------------------------------------------------------- 1 | function dy=plinear(t,y) 2 | %PLINEAR Differential equation system for desired linear pendulum. 3 | % 4 | % PLINEAR(T,Y) 5 | % T - Time. 6 | % Y - Current state of inverted pendulum. 7 | % Returns derivatives of the pendulum state. 8 | % 9 | % The state vector Y has three values: 10 | % Y(1) - Pendulum angle from -2 pi to 2 pi radians. 11 | % Y(2) - Pendulum angular velocity in radians/second. 12 | % Y(3) - Demand angle for the pendulum. 13 | % 14 | % NOTES: Angle is 0 radians when the pendulum points up. 15 | % Demand stays constant, its derivative is always 0. 16 | % 17 | % See also APPCS1, PMODEL. 18 | 19 | % Mark Beale, 12-15-93 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.11 $ $Date: 2002/03/25 16:51:13 $ 22 | 23 | if nargin < 2,error('Not enough input arguments.'), end 24 | 25 | % STATE 26 | angle = y(1); 27 | vel = y(2); 28 | demand = y(3); 29 | 30 | % CALCULATE DERIVATIVES 31 | dangle = vel; 32 | dvel = -9*angle - 6*vel + 9*demand; 33 | ddemand = 0; 34 | 35 | % RETURN DERIVATIVES 36 | dy = [dangle; dvel; ddemand]; 37 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/plotchar.m: -------------------------------------------------------------------------------- 1 | function plotchar(c) 2 | %PLOTCHAR Plot a 35 element vector as a 5x7 grid. 3 | % 4 | % PLOTCHAR(C) 5 | % C - a 35 element vector. 6 | % C's elements are plotted as a 5x7 grid. 7 | 8 | % Mark Beale, 12-15-93 9 | % Copyright 1992-2002 The MathWorks, Inc. 10 | % $Revision: 1.11 $ $Date: 2002/03/25 16:51:14 $ 11 | 12 | % DEFINE BOX 13 | x1 = [-0.5 -0.5 +0.5 +0.5 -0.5]; 14 | y1 = [-0.5 +0.5 +0.5 -0.5 -0.5]; 15 | 16 | % DEFINE BOX WITH X 17 | x2 = [x1 +0.5 +0.5 -0.5]; 18 | y2 = [y1 +0.5 -0.5 +0.5]; 19 | 20 | newplot; 21 | plot(x1*5.6+2.5,y1*7.6+3.5,'m'); 22 | axis([-1.5 6.5 -0.5 7.5]); 23 | axis('equal') 24 | axis off 25 | hold on 26 | 27 | for i=1:length(c) 28 | x = rem(i-1,5)+.5; 29 | y = 6-floor((i-1)/5)+.5; 30 | plot(x2*c(i)+x,y2*c(i)+y); 31 | end 32 | hold off 33 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/pmodel.m: -------------------------------------------------------------------------------- 1 | function dy=pmodel(t,y) 2 | %PMODEL Differential equation system for inverted pendulum. 3 | % 4 | % PMODEL(T,Y) 5 | % T - Time. 6 | % Y - Current state of inverted pendulum. 7 | % Returns derivatives of the pendulum state. 8 | % 9 | % The state vector Y has three values: 10 | % Y(1) - Pendulum angle from -2 pi to 2 pi radians. 11 | % Y(2) - Pendulum angular velocity in radians/second. 12 | % Y(3) - Force being applied to the pendulum. 13 | % 14 | % NOTES: Angle is 0 radians when the pendulum points up. 15 | % Force stays constant, its derivative is always 0. 16 | % 17 | % See also APPCS1, PLINEAR. 18 | 19 | % Mark Beale, 12-15-93 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.11 $ $Date: 2002/03/25 16:51:14 $ 22 | 23 | if nargin < 2, error('Not enough input vectors.'); end 24 | 25 | % STATE 26 | angle = y(1); 27 | vel = y(2); 28 | force = y(3); 29 | 30 | % CALCULATE DERIVATIVES 31 | dangle = vel; 32 | dvel = 9.81*sin(angle) - 2*vel + force; 33 | dforce = zeros(size(force)); 34 | 35 | % RETURN DERIVATIVES 36 | dy = [dangle; dvel; dforce]; 37 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/eegdata.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/private/eegdata.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnaxclik.m: -------------------------------------------------------------------------------- 1 | function [f,x,y] = nnaxclik(a,x,y) 2 | %NNAXCLIK Neural Network Design utility function. 3 | 4 | % [F,X,Y] = NNAXCLIK(A) 5 | % A - Axis handle. 6 | % Returns: 7 | % (X,Y) - Coordinates of last click in axis A coordinates. 8 | % F - 1 if (X,Y) is in A, otherwise returns 0. 9 | % 10 | % NNAXCLIK(A,X,Y) 11 | % Returns 1 if (X,Y) is in A, otherwise returns 0. 12 | 13 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 14 | % First Version, 8-31-95. 15 | % $Revision: 1.7 $ 16 | 17 | if nargin == 1 18 | pt = get(a,'currentpoint'); 19 | x = pt(1); 20 | y = pt(3); 21 | end 22 | xlim = get(a,'xlim'); 23 | ylim = get(a,'ylim'); 24 | f = (x >= xlim(1)) & (x <= xlim(2)) & (y >= ylim(1)) & (y <= ylim(2)); 25 | 26 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnblack.m: -------------------------------------------------------------------------------- 1 | function c = nnblack 2 | %NNBLACK Neural Network Design utility function. 3 | 4 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 5 | % First Version, 8-31-95. 6 | % $Revision: 1.6 $ 7 | 8 | c = [0 0 0]; 9 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nncallbk.m: -------------------------------------------------------------------------------- 1 | function y = nncallbk(demo,command) 2 | %NNCALLBK Neural Network Design utility function. 3 | 4 | % NNCALLBK(DEMO,COMMAND) 5 | % DEMO - Name of demo. 6 | % COMMAND - Command. 7 | % Returns string of form: DEMO('COMMAND'). 8 | 9 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 10 | % First Version, 8-31-95. 11 | % $Revision: 1.10 $ 12 | 13 | y = sprintf('%s(''%s'')',demo,command); 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nncentxt.m: -------------------------------------------------------------------------------- 1 | function h = nncentxt(s) 2 | % NNCENTXT Neural Network Design utility function. 3 | 4 | % NNCENTXT(S) 5 | % S - String. 6 | % Displays string S in current axis, and returns handle. 7 | 8 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 9 | % First Version, 8-31-95. 10 | % $Revision: 1.6 $ 11 | 12 | if nargin == 0, s = 'Neuro-Waffle'; end 13 | 14 | x = get(gca,'xlim'); 15 | y = get(gca,'ylim'); 16 | h = text(sum(x)*0.5,sum(y)*0.5,s); 17 | set(h,'horizontal','center'); 18 | set(h,'fontweight','bold'); 19 | 20 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnchkfs.m: -------------------------------------------------------------------------------- 1 | function nnchkfs 2 | % NNCHKFS Neural Network Design utility function. 3 | 4 | % Check to see if a demo figure is too small because 5 | % of a small screen resolution. 6 | % If it is then shrink figure to small size. 7 | % 8 | % Set to 1 if you want to force figures to be always small. 9 | 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % $Revision: 1.6 $ 12 | 13 | Always_Small = 0; 14 | c = computer; 15 | pos = get(gcf,'position'); 16 | if strcmp(c(1:2),'PC') | strcmp(c(1:3),'MAC') 17 | if (pos(3) < 500 | pos(4) < 400) | Always_Small 18 | nnshrink 19 | end 20 | end 21 | set(gcf,'visible','on'); 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nncolor.m: -------------------------------------------------------------------------------- 1 | function c = nncolor 2 | % NNCOLOR Neural Network Design utility function. 3 | 4 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 5 | % First Version, 8-31-95. 6 | % $Revision: 1.6 $ 7 | 8 | 9 | c = [nnblack; 10 | nnwhite; 11 | nnred; 12 | nngreen; 13 | nndkblue; 14 | nnyellow; 15 | nnltyell; 16 | nngrays]; 17 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndbp1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/private/nndbp1.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndbp2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/private/nndbp2.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndbp3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nndemos/private/nndbp3.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndfgflg.m: -------------------------------------------------------------------------------- 1 | function f=nndfgflg(n) 2 | %NNDFGFLG Neural Network Design utility function. 3 | 4 | % NNDFGFLG(N) 5 | % N - Name of figure (string). 6 | % Returns handle to figure with name N if it exists. 7 | % Returns 0, otherwise. 8 | 9 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 10 | % $Revision: 1.8 $ 11 | % First Version, 8-31-95. 12 | 13 | %================================================================== 14 | 15 | % Disable NextPlot Warning 16 | warning off MATLAB:HandleGraphics:SupersededProperty:NextPlotNew 17 | 18 | z = get(0,'children'); 19 | for i=1:length(z) 20 | typ = get(z(i),'type'); 21 | if strcmp(typ,'figure') 22 | nam = get(z(i),'name'); 23 | if strcmp(nam,n) 24 | f = z(i); 25 | return 26 | end 27 | end 28 | end 29 | 30 | f = 0; 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndkblue.m: -------------------------------------------------------------------------------- 1 | function c = nndkblue 2 | %NNDKBLUE Dark blue used by Neural Network Toolbox GUI 3 | 4 | % NNDKBLUE returns rgb triple for dark blue. 5 | 6 | % Mark Beale 6-4-94 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | % $Revision: 1.7 $ 9 | 10 | c = [0 0 0.3]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndkgray.m: -------------------------------------------------------------------------------- 1 | function c = nndkgray 2 | %NNDKGRAY Dark gray used by Neural Network Toolbox GUI. 3 | 4 | % NNDKGRAY returns rgb triple for dark gray. 5 | 6 | % Mark Beale 6-4-94 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | % $Revision: 1.7 $ 9 | 10 | c = [0.4 0.4 0.4]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndrawax.m: -------------------------------------------------------------------------------- 1 | function h=nndrawax(c,e) 2 | %NNDRAWAX Neural Network Design utility function. 3 | 4 | % NNDRAWAX(C) 5 | % C - Color (default = dark blue). 6 | % E - Erase mode (default = 'normal'); 7 | % Draws the x- and y-axes on a plot with color C. 8 | 9 | % First Version, 8-31-95. 10 | % $Revision: 1.7 $ 11 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 12 | 13 | %================================================================== 14 | 15 | % DEFAULTS 16 | if nargin < 1, c = nndkblue; end 17 | if nargin < 2, e = 'normal'; end 18 | 19 | ca = gca; 20 | NP = get(ca ,'nextplot'); 21 | set(ca ,'nextplot','add') 22 | 23 | xlim = get(ca,'xlim'); 24 | xmin = xlim(1); 25 | xmax = xlim(2); 26 | ylim = get(ca,'ylim'); 27 | ymin = ylim(1); 28 | ymax = ylim(2); 29 | g = plot([xmin xmax NaN 0 0],[0 0 NaN ymax ymin],':',... 30 | 'color',c,... 31 | 'erasemode',e); 32 | 33 | set(ca,'nextplot',NP) 34 | 35 | if nargout, h = g; end 36 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndrwcir.m: -------------------------------------------------------------------------------- 1 | function nndrwcir(x,y,r,c) 2 | %NNDRWCIR Neural Network Design utility function. 3 | 4 | % NNDRWCIR(X,Y,R,C) 5 | % X - Horizontal coordinate. 6 | % Y - Vertical coordinate. 7 | % R - Radius. 8 | % C - Color. 9 | % Draws a filled circle. 10 | 11 | % First Version, 8-31-95. 12 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 13 | % $Revision: 1.7 $ 14 | 15 | %================================================================== 16 | 17 | angle = [0:10:350] * pi/180; 18 | fill(cos(angle)*r+x,sin(angle)*r+y,c,'edgecolor','none'); 19 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndrwrec.m: -------------------------------------------------------------------------------- 1 | function h = nndrwrec(x,y,w,h,c) 2 | %NNDRWREC Neural Network Design utility function. 3 | 4 | % NNDRWREC(X,Y,W,H,C) 5 | % X - Horizontal coordinate. 6 | % Y - Vertical coordinate. 7 | % W - Width of rectangle. 8 | % H - Height of rectangle. 9 | % C - Color 10 | % Draws a rectangle. 11 | 12 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 13 | % $Revision: 1.7 $ 14 | % First Version, 8-31-95. 15 | 16 | %================================================================== 17 | 18 | sqr_x = [0 1 1 0 0]; 19 | sqr_y = [0 0 1 1 0]; 20 | g = fill(sqr_x*w+x,sqr_y*h+y,c,'edgecolor','none'); 21 | if nargout, h = g; end 22 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nndtext.m: -------------------------------------------------------------------------------- 1 | function h=nndtext(t,x,y,a) 2 | %NNDTEXT Neural Network Design utility function. 3 | 4 | % NNDTEXT(T,X,Y) 5 | % T - Text (string). 6 | % X - Horizontal coordinate. 7 | % Y - Vertical coordinate. 8 | % A - Horizontal alignment (default = 'center'). 9 | % Draws text T at location (X,Y) in bold and NNDKBLUE and 10 | % erasemode of 'none'. Optionally returns handle to text. 11 | 12 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 13 | % First Version, 8-31-95. 14 | % $Revision: 1.7 $ 15 | 16 | %================================================================== 17 | 18 | % DEFAULTS 19 | if nargin < 4, a = 'center'; end 20 | 21 | % DRAW 22 | H = text(t,x,y,... 23 | 'color',nndkblue',... 24 | 'fontweight','bold',... 25 | 'horiz',a,... 26 | 'erasemode','none'); 27 | 28 | % RETURN VALUE 29 | if nargout, h = H; end 30 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnfgflag.m: -------------------------------------------------------------------------------- 1 | function f=nnfgflag(n) 2 | %NNFGFLAG Neural Network Design utility function. 3 | 4 | % NNFGFLAG(N) 5 | % N - Name of figure (string). 6 | % Returns handle to figure with name N if it exists. 7 | % Returns 0, otherwise. 8 | 9 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 10 | % First Version, 8-31-95. 11 | % $Revision: 1.11 $ 12 | 13 | %================================================================== 14 | 15 | z = get(0,'children'); 16 | for i=1:length(z) 17 | typ = get(z(i),'type'); 18 | if strcmp(typ,'figure') 19 | nam = get(z(i),'name'); 20 | if strcmp(nam,n) 21 | f = z(i); 22 | return 23 | end 24 | end 25 | end 26 | 27 | f = 0; 28 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nngetclk.m: -------------------------------------------------------------------------------- 1 | function [x,y] = nngetclk(s) 2 | %NNGETCLK Get coordinates by mouse click from user. 3 | % 4 | % [X,Y] = NNGETCLK(S) 5 | % S - String to display in axis (default = '< CLICK ME >'). 6 | % Returns: 7 | % X - Horizontal coordinate of mouse click. 8 | % Y - Vertical coordinate. 9 | 10 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 11 | % $Revision: 1.7 $ 12 | 13 | % DEFAULT 14 | 15 | if nargin < 1, s = '< CLICK ME>'; end 16 | 17 | % DISPLAY TEXT, GET CLICK, REMOVE TEXT 18 | 19 | th = nncentxt(s); set(th,'color',nndkblue); 20 | [x,y] = ginput(1); 21 | delete(th) 22 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nngrays.m: -------------------------------------------------------------------------------- 1 | function c = nngrays 2 | %NNGRAYS Grays used by Neural Network Toolbox GUI. 3 | 4 | % NNGRAYS returns a matrix of rgb triples for 46 grays. 5 | 6 | % Mark Beale 6-4-94 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | % $Revision: 1.7 $ 9 | 10 | c = [0.9:-0.01:0.4]'*[1 0.97 0.97]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nngreen.m: -------------------------------------------------------------------------------- 1 | function c = nngreen 2 | %NNGREEN Green used by Neural Network Toolbox GUI. 3 | 4 | % NNGREEN returns rgb triple for green. 5 | 6 | % Mark Beale 6-4-94 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | % $Revision: 1.7 $ 9 | 10 | c = [0 0.7 0]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnlmarq.m: -------------------------------------------------------------------------------- 1 | function jac = nnlmarq(p,d) 2 | %NNLMARQ Marquardt Backpropagation Learning Rule 3 | % 4 | % (See PURELIN, LOGSIG, TANSIG) 5 | % 6 | % jac = NNLMARQ(P,D) 7 | % P - RxQ matrix of input vectors. 8 | % D - SxQ matrix of sensitivity vectors. 9 | % Returns: 10 | % jac - a partial jacobian matrix. 11 | 12 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 13 | % $Revision: 1.6 $ 14 | 15 | 16 | if nargin ~= 2 17 | error('Wrong number of arguments.'); 18 | end 19 | 20 | [s,q]=size(d); 21 | [r,q]=size(p); 22 | 23 | jac=kron(p',ones(1,s)).*kron(ones(1,r),d'); 24 | 25 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnltblue.m: -------------------------------------------------------------------------------- 1 | function c=nnltblue 2 | %NNLTBLUE Neural Network Design utility function. 3 | 4 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 5 | % $Revision: 1.6 $ 6 | 7 | c = [0.5 0.5 1]; 8 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnltgray.m: -------------------------------------------------------------------------------- 1 | function c = nnltgray 2 | %NNLTGRAY Neural Network Design utility function. 3 | 4 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 5 | % $Revision: 1.6 $ 6 | % First Version, 8-31-95. 7 | 8 | %================================================================== 9 | 10 | 11 | c = [0.68 0.68 0.68]; 12 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnltyell.m: -------------------------------------------------------------------------------- 1 | function c = nnltyell 2 | %NNLTYELL Neural Network Design utility function. 3 | 4 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 5 | % $Revision: 1.6 $ 6 | % First Version, 8-31-95. 7 | 8 | %================================================================== 9 | 10 | c = [1 1 0.6]*0.95; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnmdgray.m: -------------------------------------------------------------------------------- 1 | function c = nnmdgray 2 | %NNMDGRAY Neural Network Design utility function. 3 | 4 | % $Revision: 1.6 $ 5 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 6 | % First Version, 8-31-95. 7 | 8 | %================================================================== 9 | 10 | c = [0.55 0.55 0.55]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnmdlin.m: -------------------------------------------------------------------------------- 1 | function d = nnmdlin(a,d,w) 2 | %NNMDLIN Logistic Delta Function for Marquardt. 3 | % Returns the delta values for a layer of 4 | % linear neurons. 5 | % (See MDELTALOG,MDELTATAN,LEARN_MARQ,PURELIN) 6 | % 7 | % NNMDLIN(A) 8 | % Returns a matrix of delta vectors for an ouput 9 | % layer. 10 | % 11 | % NNMDLIN(A,D,W), D is an S2xQ matrix, 12 | % W is an S2xS1 matrix. 13 | % Returns a matrix of delta vectors for a hidden 14 | % layer of linear neurons whose outputs have 15 | % been passed through a weight matrix W to another 16 | % layer with delta vectors D. 17 | 18 | % $Revision: 1.6 $ 19 | % First Version, 8-31-95. 20 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 21 | 22 | 23 | %================================================================== 24 | 25 | [na,ma]=size(a); 26 | 27 | if nargin == 1 28 | d=-kron(ones(1,ma),eye(na)); 29 | else 30 | d = w'*d; 31 | end 32 | 33 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnpause.m: -------------------------------------------------------------------------------- 1 | function nnpause(delay) 2 | %NNPAUSE A Neural Network Design utility function. 3 | 4 | % $Revision: 1.6 $ 5 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 6 | % First Version, 8-31-95. 7 | 8 | %================================================================== 9 | 10 | drawnow 11 | start = clock; 12 | while etime(clock,start) < delay,end 13 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnpin.m: -------------------------------------------------------------------------------- 1 | function y = nnpin(x,a,b,q) 2 | %NNPIN Neural Network Design utility function. 3 | 4 | % NNPIN(X,A,B,Q) 5 | % X - Number or matrix. 6 | % A - Lower bound. 7 | % B - Upper bound. 8 | % Q - Quantization constant (optional). 9 | % Returns values in X pinned into the interval defined 10 | % by A and B and rounded to the nearest multiple of Q. 11 | 12 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 13 | % $Revision: 1.7 $ 14 | % First Version, 8-31-95. 15 | 16 | %================================================================== 17 | 18 | y = max(a,min(b,x)); 19 | y = round(y/q)*q; 20 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnred.m: -------------------------------------------------------------------------------- 1 | function c = nnred 2 | %NNRED Neural Network Design utility function. 3 | 4 | % $Revision: 1.6 $ 5 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 6 | % First Version, 8-31-95. 7 | 8 | %================================================================== 9 | 10 | c = [1 0.1 0.1]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnstuded.m: -------------------------------------------------------------------------------- 1 | function f=nnstuded 2 | %NNSTUDED Neural Network Design utility function. 3 | 4 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 5 | % $Revision: 1.6 $ 6 | 7 | % Returns 1 if Student Edition MATLAB is being used. 8 | 9 | c = version; 10 | f=0; 11 | if length(c) >= 7 12 | if lower(c(1:7)) == 'student' 13 | f = 1; 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nntfnms.m: -------------------------------------------------------------------------------- 1 | function n = nntfnms 2 | %NNTFNMS Neural Network Design utility function. 3 | 4 | % $Revision: 1.6 $ 5 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 6 | % First Version, 8-31-95. 7 | 8 | %================================================================== 9 | 10 | n = ['compet '; 11 | 'hardlim '; 12 | 'hardlims'; 13 | 'logsig '; 14 | 'purelin '; 15 | 'radbas '; 16 | 'satlin '; 17 | 'satlins '; 18 | 'tansig ']; 19 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nntxtchk.m: -------------------------------------------------------------------------------- 1 | function nntxtchk 2 | %NNTXTCHK Neural Network Design utility function. 3 | 4 | % Refresh screen when appropriate to get around PC text color bug. 5 | 6 | % $Revision: 1.6 $ 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | 9 | c = computer; 10 | if strcmp(c(1:2),'PC') 11 | set(gcf,'Position',get(gcf,'Position')); 12 | end 13 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnwhite.m: -------------------------------------------------------------------------------- 1 | function c = nnwhite 2 | %NNWHITE White used by Neural Network Toolbox GUI 3 | 4 | % NNWHITE returns rgb triple for white. 5 | 6 | % Mark Beale 6-4-94 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | % $Revision: 1.7 $ 9 | 10 | c = [1 1 1]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nndemos/private/nnyellow.m: -------------------------------------------------------------------------------- 1 | function c = nnyellow 2 | %NNYELLOW Yellow used by Neural Network Toolbox GUI. 3 | 4 | % NNYELLOW returns rgb triple for yellow. 5 | 6 | % Mark Beale 6-4-94 7 | % Copyright 1994-2002 PWS Publishing Company and The MathWorks, Inc. 8 | % $Revision: 1.7 $ 9 | 10 | c = [1 1 0]; 11 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/display.m: -------------------------------------------------------------------------------- 1 | function display(net) 2 | %DISPLAY Display the name and properties of a neural network variable. 3 | % 4 | % Syntax 5 | % 6 | % display(net) 7 | % 8 | % Description 9 | % 10 | % DISPLAY(NET) displays a network variable's name and properties. 11 | % 12 | % Examples 13 | % 14 | % Here a perceptron variable is defined and displayed. 15 | % 16 | % net = newp([-1 1; 0 2],3); 17 | % display(net) 18 | % 19 | % DISPLAY is automatically called as follows: 20 | % 21 | % net 22 | % 23 | % See also DISP, SIM, INIT, TRAIN, ADAPT 24 | 25 | % Mark Beale, 11-31-97 26 | % Copyright 1992-2002 The MathWorks, Inc. 27 | % $Revision: 1.7 $ 28 | 29 | isLoose = strcmp(get(0,'FormatSpacing'),'loose'); 30 | 31 | if (isLoose), fprintf('\n'), end 32 | 33 | fprintf('%s =\n',inputname(1)); 34 | 35 | disp(net) 36 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/loadobj.m: -------------------------------------------------------------------------------- 1 | function net = loadobj(obj) 2 | %LOADOBJ Load a network object. 3 | 4 | % Copyright 1992-2002 The MathWorks, Inc. 5 | % $Revision: 1.4 $ $Date: 2002/03/25 16:53:03 $ 6 | 7 | if isa(obj,'network') 8 | net = obj; 9 | else 10 | net = updatenet(obj); 11 | end 12 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/active.m: -------------------------------------------------------------------------------- 1 | function y=active(x) 2 | %ACTIVE Returns number of structures in cell array. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | y = 0; 9 | for i=1:size(x,1) 10 | for j=1:size(x,2) 11 | if isa(x{i,j},'struct') 12 | y=y+1; 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/boolstr.m: -------------------------------------------------------------------------------- 1 | function s=boolstr(b) 2 | %BOOLSTR Create string summary of a boolean matrix. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if prod(size(b)) > 12 9 | s = sprintf('[%gx%g boolean]',size(b,1),size(b,2)); 10 | else 11 | s = '['; 12 | for i=1:size(b,1) 13 | if (i > 1) 14 | s = [s '; ']; 15 | end 16 | for j=1:size(b,2) 17 | if (j > 1) 18 | s = [s sprintf(' %g',b(i,j))]; 19 | else 20 | s = [s sprintf('%g',b(i,j))]; 21 | end 22 | end 23 | end 24 | s = [s ']']; 25 | end 26 | 27 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/formatp.m: -------------------------------------------------------------------------------- 1 | function [err,c] = formatp(net,m,Q) 2 | %FORMATP Format matrix P. 3 | % 4 | % Synopsis 5 | % 6 | % [err,P] = formatp(net,P,Q) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code dependant on this function. 13 | 14 | % Mark Beale, 11-31-97 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.8 $ 17 | 18 | err = []; 19 | c = []; 20 | 21 | % Check number of rows 22 | if (size(m,1) ~= net.hint.totalInputSize) 23 | err = sprintf('Inputs are incorrectly sized for network.\nMatrix must have %g rows.',net.hint.totalInputSize); 24 | return 25 | end 26 | if (size(m,2) ~= Q) 27 | err = sprintf('Inputs are incorrectly sized.\nMatrix must have %g columns.',Q); 28 | return 29 | end 30 | 31 | % Cell -> Matrix 32 | c = mat2cell(m,net.hint.inputSizes); 33 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/formatt.m: -------------------------------------------------------------------------------- 1 | function [err,c] = formatt(net,m,Q,TS) 2 | %FORMATT Format matrix T. 3 | % 4 | % Synopsis 5 | % 6 | % [err,T] = formatt(net,T,Q) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code dependant on this function. 13 | 14 | % Mark Beale, 11-31-97 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.8 $ 17 | 18 | err = []; 19 | c = []; 20 | 21 | % [] -> zeros 22 | if any(size(m) == 0) 23 | c = cell(net.numTargets,TS); 24 | for i=1:net.numTargets 25 | for ts=1:TS 26 | c{i,ts} = zeros(net.hint.targetSizes(i),Q); 27 | end 28 | end 29 | return 30 | end 31 | 32 | % Check number of rows 33 | if (size(m,1) ~= net.hint.totalTargetSize) 34 | err = sprintf('Targets are incorrectly sized for network.\nMatrix must have %g rows.',net.hint.totalTargetSize); 35 | return 36 | end 37 | if (size(m,2) ~= Q) 38 | err = sprintf('Targets are incorrectly sized for network.\nMatrix must have %g columns.',Q); 39 | return 40 | end 41 | 42 | % Cell -> Matrix 43 | c = mat2cell(m,net.hint.targetSizes); 44 | 45 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/hasfield.m: -------------------------------------------------------------------------------- 1 | function f=hasfield(s,n) 2 | %HADFIELD Does structure have a field. 3 | % 4 | % Syntax 5 | % 6 | % hasfield(S,N) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code which calls this function. 13 | 14 | % Mark Beale, 11-31-97 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.7 $ 17 | 18 | f = 0; 19 | fn = fieldnames(s); 20 | for i=1:length(fn) 21 | if strcmp(fn{i},n) 22 | f = 1; 23 | break; 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isbias.m: -------------------------------------------------------------------------------- 1 | function f=isbias(s) 2 | %ISBIAS True if input is an NNBIAS structure. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if nnstruct(s,'nnbias') 9 | f = 1; 10 | elseif isa(s,'double') & (prod(size(s)) == 0) 11 | f = 1; 12 | else 13 | f = 0; 14 | end 15 | 16 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isbool.m: -------------------------------------------------------------------------------- 1 | function f=isbool(v,r,c) 2 | %ISBOOL True for properly sized boolean matrices. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.8 $ 7 | 8 | if islogical(v) 9 | f = all(size(v) == [r c]); 10 | return; 11 | end 12 | 13 | f = 1; 14 | 15 | if ~isa(v,'double') | any(size(v) ~= [r c]) 16 | f = 0; 17 | elseif (prod(size(v)) > 0) & any((v ~= 0) & (v ~= 1)) 18 | f = 0; 19 | end 20 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isempmat.m: -------------------------------------------------------------------------------- 1 | function f=isempmat(m) 2 | %ISEMPMAT True if input is an empty matrix. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if isa(m,'double') 9 | if any(size(m) == [0 0]) 10 | f = 1; 11 | else 12 | f = 0; 13 | end 14 | 15 | % MOVE THIS TO ANOTHER FUNCTION ******* 16 | elseif isa(m,'cell') 17 | [r,c] = size(m); 18 | f = zeros(r,c); 19 | for i=1:r 20 | for j=1:c 21 | f(i,j) = ~isempmat(m{i,j}); 22 | end 23 | end 24 | 25 | else 26 | f = 0; 27 | end 28 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isinput.m: -------------------------------------------------------------------------------- 1 | function f=isinput(s) 2 | %ISINPUT True if input is an NNINPUT structure. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if ~nnstruct(s,'nninput') 9 | f = 0; 10 | else 11 | f = 1; 12 | end 13 | 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/islayer.m: -------------------------------------------------------------------------------- 1 | function f=islayer(s) 2 | %ISLAYER True if input is an NNLAYER structure. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if ~nnstruct(s,'nnlayer') 9 | f = 0; 10 | else 11 | f = 1; 12 | end 13 | 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isnif.m: -------------------------------------------------------------------------------- 1 | function f=isnif(s) 2 | %ISNIF True of input is name of a net input function. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | f = 1; 9 | if ~isa(s,'char') | ~any(exist(s) == [2 3 6]) 10 | f = 0; 11 | else 12 | % Check NIF info 13 | end 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isoutput.m: -------------------------------------------------------------------------------- 1 | function f=isoutput(s) 2 | %ISOUTPUT True if input is an NNOUTPUT structure. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if ~nnstruct(s,'nnoutput') 9 | f = 0; 10 | else 11 | f = 1; 12 | end 13 | 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isposint.m: -------------------------------------------------------------------------------- 1 | function f=isposint(v) 2 | %ISPOSINT True for positive integer values. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | f = 1; 9 | if ~isa(v,'double') | any(size(v) ~= [1 1]) | ... 10 | ~isreal(v) | v<0 | round(v) ~= v 11 | f = 0; 12 | end 13 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/istf.m: -------------------------------------------------------------------------------- 1 | function f=istf(s) 2 | %ISTF True of input is name of transfer function. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | f = 1; 9 | if ~isa(s,'char') | ~any(exist(s) == [2 3 6]) 10 | f = 0; 11 | else 12 | % Check TF info 13 | end 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/@network/private/isweight.m: -------------------------------------------------------------------------------- 1 | function f=isweight(s) 2 | %ISWEIGHT True if input is an NNWEIGHT structure. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.7 $ 7 | 8 | if nnstruct(s,'nnweight') 9 | f = 1; 10 | elseif isa(s,'double') & (prod(size(s)) == 0) 11 | f = 1; 12 | else 13 | f = 0; 14 | end 15 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dhardlim.m: -------------------------------------------------------------------------------- 1 | function d=dhardlim(n,a) 2 | %DHARDLIM Derivative of hard limit transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dhardlim(N,A) 7 | % 8 | % Description 9 | % 10 | % DHARDLIM is the derivative function for HARDLIM. 11 | % 12 | % DHARDLIM(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 HARDLIM 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with HARDLIM and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = hardlim(N) 28 | % dA_dN = dhardlim(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of HARDLIM is calculated as follows: 33 | % 34 | % d = 0 35 | % 36 | % See also HARDLIM. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = zeros(size(n)); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dhardlms.m: -------------------------------------------------------------------------------- 1 | function d=dhardlms(n,a) 2 | %DHARDLMS Derivative of symmetric hard limit transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dhardlms(N,A) 7 | % 8 | % Description 9 | % 10 | % DHARDLMS is the derivative function for HARDLIMS. 11 | % 12 | % DHARDLMS(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 HARDLIMS 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with HARDLIMS and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = hardlims(N) 28 | % dA_dN = dhardlms(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of HARDLIMS is calculated as follows: 33 | % 34 | % d = 0 35 | % 36 | % See also HARDLIMS. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = zeros(size(n)); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dlogsig.m: -------------------------------------------------------------------------------- 1 | function d=dlogsig(n,a) 2 | %DLOGSIG Log sigmoid transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dlogsig(N,A) 7 | % 8 | % Description 9 | % 10 | % DLOGSIG is the derivative function for LOGSIG. 11 | % 12 | % DLOGSIG(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 TANSIG 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with LOGSIG and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = logsig(N) 28 | % dA_dN = dlogsig(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of LOGSIG is calculated as follows: 33 | % 34 | % d = a * (1 - a) 35 | % 36 | % See also LOGSIG, TANSIG, DTANSIG. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = a.*(1-a); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dnetprod.m: -------------------------------------------------------------------------------- 1 | function d=dnetprod(z,n) 2 | %DNETPROD Derivative of net input product function. 3 | % 4 | % Syntax 5 | % 6 | % dN_dZ = dnetprod(Z,N) 7 | % 8 | % Description 9 | % 10 | % DNETPROD is the net input derivative function for NETPROD. 11 | % 12 | % DNETPROD takes two arguments, 13 | % Z - SxQ weighted input. 14 | % N - SxQ net input. 15 | % and returns the SxQ derivative dN/dZ. 16 | % 17 | % Examples 18 | % 19 | % Here we define two weighted inputs for a layer with 20 | % three neurons. 21 | % 22 | % Z1 = [0.1; 1; -1]; 23 | % Z2 = [1; 0.5; 1.2]; 24 | % 25 | % We calculate the layer's net input N with NETPROD and then 26 | % the derivative of N with respect to each weighted input. 27 | % 28 | % N = netprod(Z1,Z2) 29 | % dN_dZ1 = dnetprod(Z1,N) 30 | % dN_dZ2 = dnetprod(Z2,N) 31 | % 32 | % Algorithm 33 | % 34 | % The derivative a product with respect to any element of that 35 | % product is the product of the other elements. 36 | % 37 | % See also NETSUM, NETPROD, DNETSUM. 38 | 39 | % Mark Beale, 11-31-97 40 | % Copyright 1992-2002 The MathWorks, Inc. 41 | % $Revision: 1.8 $ 42 | 43 | d = n./z; 44 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dnetsum.m: -------------------------------------------------------------------------------- 1 | function d=dnetsum(z,n) 2 | %DNETSUM Sum net input derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dN_dZ = dnetsum(Z,N) 7 | % 8 | % Description 9 | % 10 | % DNETSUM is the net input derivative function for NETSUM. 11 | % 12 | % DNETSUM takes two arguments, 13 | % Z - SxQ weighted input. 14 | % N - SxQ net input. 15 | % and returns the SxQ derivative dN/dZ. 16 | % 17 | % Examples 18 | % 19 | % Here we define two weighted inputs for a layer with 20 | % three neurons. 21 | % 22 | % Z1 = [0; 1; -1]; 23 | % Z2 = [1; 0.5; 1.2]; 24 | % 25 | % We calculate the layer's net input N with NETSUM and then 26 | % the derivative of N with respect to each weighted input. 27 | % 28 | % N = netsum(Z1,Z2) 29 | % dN_dZ1 = dnetsum(Z1,N) 30 | % dN_dZ2 = dnetsum(Z2,N) 31 | % 32 | % Algorithm 33 | % 34 | % The derivative of a sum with respect to any element of that 35 | % sum is always a ones matrix that is the same size as the sum. 36 | % 37 | % See also NETSUM, NETPROD, DNETPROD. 38 | 39 | % Mark Beale, 11-31-97 40 | % Copyright 1992-2002 The MathWorks, Inc. 41 | % $Revision: 1.7 $ 42 | 43 | d = ones(size(z)); 44 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dposlin.m: -------------------------------------------------------------------------------- 1 | function d=dposlin(n,a) 2 | %DPOSLIN Derivative of positive linear transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dposlin(N,A) 7 | % 8 | % Description 9 | % 10 | % DPOSLIN is the derivative function for POSLIN. 11 | % 12 | % DPOSLIN(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 POSLIN 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with POSLIN and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = poslin(N) 28 | % dA_dN = dposlin(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of POSLIN is calculated as follows: 33 | % 34 | % d = 1, if 0 <= n 35 | % 0, otherwise 36 | % 37 | % See also POSLIN. 38 | 39 | % Mark Beale, 11-31-97 40 | % Copyright 1992-2002 The MathWorks, Inc. 41 | % $Revision: 1.7 $ 42 | 43 | d = (n >= 0); 44 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dpurelin.m: -------------------------------------------------------------------------------- 1 | function d=dpurelin(n,a) 2 | %DPURELIN Linear transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dpurelin(N,A) 7 | % 8 | % Description 9 | % 10 | % DPURELIN is the derivative function for LOGSIG. 11 | % 12 | % DPURELIN(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 PURELIN 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with PURELIN and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = purelin(N) 28 | % dA_dN = dpurelin(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of PURELIN is calculated as follows: 33 | % 34 | % D(i,q) = 1 35 | % 36 | % See also PURELIN. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = ones(size(n)); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dradbas.m: -------------------------------------------------------------------------------- 1 | function d=dradbas(n,a) 2 | %DRADBAS Derivative of radial basis transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dradbas(N,A) 7 | % 8 | % Description 9 | % 10 | % DRADBAS is the derivative function for RADBAS. 11 | % 12 | % DRADBAS(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 RADBAS 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with RADBAS and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = radbas(N) 28 | % dA_dN = dradbas(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of RADBAS is calculated as follows: 33 | % 34 | % d = -2*n*a 35 | % 36 | % See also RADBAS. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = (-2)*(n.*a); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dsatlin.m: -------------------------------------------------------------------------------- 1 | function d=dsatlin(n,a) 2 | %DSATLIN Derivative of saturating linear transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dsatlin(N,A) 7 | % 8 | % Description 9 | % 10 | % DSATLIN is the derivative function for SATLIN. 11 | % 12 | % DSATLIN(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 SATLIN 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with SATLIN and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = satlin(N) 28 | % dA_dN = dsatlin(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of SATLIN is calculated as follows: 33 | % 34 | % d = 1, if 0 <= n <= 1 35 | % 0, otherwise 36 | % 37 | % See also SATLIN. 38 | 39 | % Mark Beale, 11-31-97 40 | % Copyright 1992-2002 The MathWorks, Inc. 41 | % $Revision: 1.7 $ 42 | 43 | d = (n >= 0) & (n <= 1); 44 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dsatlins.m: -------------------------------------------------------------------------------- 1 | function d=dsatlins(n,a) 2 | %DSATLINS Derivative of symmetric saturating linear transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dsatlins(N,A) 7 | % 8 | % Description 9 | % 10 | % DSATLINS is the derivative function for SATLINS. 11 | % 12 | % DSATLINS(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 SATLINS 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with SATLINS and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = satlins(N) 28 | % dA_dN = dsatlins(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of SATLINS is calculated as follows: 33 | % 34 | % d = 1, if -1 <= n <= 1 35 | % 0, otherwise 36 | % 37 | % See also SATLINS. 38 | 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = (n >= -1) & (n <= 1); 43 | 44 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dtansig.m: -------------------------------------------------------------------------------- 1 | function d=dtansig(n,a) 2 | %DTANSIG Hyperbolic tangent sigmoid transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dtansig(N,A) 7 | % 8 | % Description 9 | % 10 | % DTANSIG is the derivative function for TANSIG. 11 | % 12 | % DTANSIG(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 TANSIG 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with TANSIG and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = tansig(N) 28 | % dA_dN = dtansig(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of TANSIG is calculated as follows: 33 | % 34 | % d = 1-a^2 35 | % 36 | % See also TANSIG, LOGSIG, DLOGSIG. 37 | 38 | % Mark Beale, 11-31-97 39 | % Copyright 1992-2002 The MathWorks, Inc. 40 | % $Revision: 1.7 $ 41 | 42 | d = 1-(a.*a); 43 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/dtribas.m: -------------------------------------------------------------------------------- 1 | function d=dtribas(n,a) 2 | %DTRIBAS Derivative of triangular basis transfer function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dtribas(N,A) 7 | % 8 | % Description 9 | % 10 | % DTRIBAS is the derivative function for TRIBAS. 11 | % 12 | % DTRIBAS(N,A) takes two arguments, 13 | % N - SxQ net input. 14 | % A - SxQ output. 15 | % and returns the SxQ derivative dA/dN. 16 | % 17 | % Examples 18 | % 19 | % Here we define the net input N for a layer of 3 TRIBAS 20 | % neurons. 21 | % 22 | % N = [0.1; 0.8; -0.7]; 23 | % 24 | % We calculate the layer's output A with TRIBAS and then 25 | % the derivative of A with respect to N. 26 | % 27 | % A = tribas(N) 28 | % dA_dN = dtribas(N,A) 29 | % 30 | % Algorithm 31 | % 32 | % The derivative of TRIBAS is calculated as follows: 33 | % 34 | % d = 1, if -1 <= n < 0 35 | % -1, if 0 < n <= 1 36 | % 0, otherwise 37 | % 38 | % See also TRIBAS. 39 | 40 | % Mark Beale, 11-31-97 41 | % Copyright 1992-2002 The MathWorks, Inc. 42 | % $Revision: 1.7 $ 43 | 44 | d = (abs(n) <= 1) .* sign(-n); 45 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/errsurf.m: -------------------------------------------------------------------------------- 1 | function m = errsurf(p,t,wv,bv,f) 2 | %ERRSURF Error surface of single input neuron. 3 | % 4 | % Syntax 5 | % 6 | % E = errsurf(P,T,WV,BV,F) 7 | % 8 | % Description 9 | % 10 | % ERRSURF(P,T,WV,BV,F) takes these arguments, 11 | % P - 1xQ matrix of input vectors. 12 | % T - 1xQ matrix of target vectors. 13 | % WV - Row vector of values of W. 14 | % BV - Row vector of values of B. 15 | % F - Transfer function (string). 16 | % and returns a matrix of error values over WV and BV. 17 | % 18 | % Examples 19 | % 20 | % p = [-6.0 -6.1 -4.1 -4.0 +4.0 +4.1 +6.0 +6.1]; 21 | % t = [+0.0 +0.0 +.97 +.99 +.01 +.03 +1.0 +1.0]; 22 | % wv = -1:.1:1; bv = -2.5:.25:2.5; 23 | % es = errsurf(p,t,wv,bv,'logsig'); 24 | % plotes(wv,bv,es,[60 30]) 25 | % 26 | % See also PLOTES. 27 | 28 | % Mark Beale, 1-31-92. 29 | % Revised 12-15-93, MB 30 | % Copyright 1992-2002 The MathWorks, Inc. 31 | % $Revision: 1.11 $ $Date: 2002/03/25 16:52:42 $ 32 | 33 | if nargin < 5,error('Not enough input arguments.');end 34 | 35 | m = zeros(length(bv),length(wv)); 36 | for Y=1:length(bv); 37 | m(Y,:) = sum((t'*ones(1,length(wv))-feval(f,p'*wv+bv(Y))).^2,1); 38 | end 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/ind2vec.m: -------------------------------------------------------------------------------- 1 | function v=ind2vec(i) 2 | %IND2VEC Convert indices to vectors. 3 | % 4 | % Syntax 5 | % 6 | % vec = ind2vec(ind) 7 | % 8 | % Description 9 | % 10 | % IND2VEC and VEC2IND allow indices to be represented 11 | % either by themselves, or as vectors containing a 1 in the 12 | % row of the index they represent. 13 | % 14 | % IND2VEC(IND) takes one argument, 15 | % IND - Row vector of indices. 16 | % and returns sparse matrix of vectors, with one 1 in 17 | % each column, as indicated by IND. 18 | % 19 | % Examples 20 | % 21 | % Here four indices are defined and converted to vector 22 | % representation. 23 | % 24 | % ind = [1 3 2 3] 25 | % vec = ind2vec(ind) 26 | % 27 | % See also VEC2IND. 28 | 29 | % Mark Beale, 2-15-96. 30 | % Copyright 1992-2002 The MathWorks, Inc. 31 | % $Revision: 1.10 $ 32 | 33 | vectors = length(i); 34 | v = sparse(i,1:vectors,ones(1,vectors)); 35 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/info.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 4 | Neural Network 5 | toolbox 6 | $toolbox/matlab/icons/matlabicon.gif 7 | 8 | 9 | 10 | 11 | 12 | nntool 13 | $toolbox/matlab/icons/figureicon.gif 14 | 15 | 16 | 17 | 18 | doc nnet/ 19 | $toolbox/matlab/icons/book_mat.gif 20 | 21 | 22 | 23 | 24 | demo toolbox Neural 25 | $toolbox/matlab/icons/demoicon.gif 26 | 27 | 28 | 29 | 30 | web http://www.mathworks.com/products/neuralnet/ -browser; 31 | $toolbox/matlab/icons/webicon.gif 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/ja/info.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nnet/ja/info.xml -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/minmax.m: -------------------------------------------------------------------------------- 1 | function pr=minmax(p) 2 | %MINMAX Ranges of matrix rows. 3 | % 4 | % Syntax 5 | % 6 | % pr = minmax(p) 7 | % 8 | % Description 9 | % 10 | % MINMAX(P) takes one argument, 11 | % P - RxQ matrix. 12 | % and returns the Rx2 matrix PR of minimum and maximum values 13 | % for each row of P. 14 | % 15 | % Alternately, P can be an MxN cell array of matrices. Each matrix 16 | % P{i,j} should Ri rows and Q columns. In this case, MINMAX returns 17 | % an Mx1 cell array where the mth matrix is an Rix2 matrix of the 18 | % minimum and maximum values of elements for the matrics on the 19 | % ith row of P. 20 | % 21 | % Examples 22 | % 23 | % p = [0 1 2; -1 -2 -0.5] 24 | % pr = minmax(p) 25 | % 26 | % p = {[0 1; -1 -2] [2 3 -2; 8 0 2]; [1 -2] [9 7 3]}; 27 | % pr = minmax(p) 28 | 29 | % Mark Beale, 11-31-97 30 | % Copyright 1992-2002 The MathWorks, Inc. 31 | % $Revision: 1.11 $ 32 | 33 | 34 | if iscell(p) 35 | [m,n] = size(p); 36 | pr = cell(m,1); 37 | for i=1:m 38 | pr{i} = minmax([p{i,:}]); 39 | end 40 | elseif isa(p,'double') 41 | pr = [min(p,[],2) max(p,[],2)]; 42 | else 43 | error('Argument has illegal type.') 44 | end 45 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/nncopy.m: -------------------------------------------------------------------------------- 1 | function y=nncopy(x,m,n) 2 | %NNCOPY Copy matrix or cell array. 3 | % 4 | % Syntax 5 | % 6 | % nncopy(x,m,n) 7 | % 8 | % Description 9 | % 10 | % NNCOPY(X,M,N) takes two arguments, 11 | % X - RxC matrix (or cell array). 12 | % M - Number of vertical copies. 13 | % N - Number of horizontal copies. 14 | % and returns a new (R*M)x(C*N) matrix (or cell array). 15 | % 16 | % Examples 17 | % 18 | % x1 = [1 2 3; 4 5 6]; 19 | % y1 = nncopy(x1,3,2) 20 | % x2 = {[1 2]; [3; 4; 5]} 21 | % y2 = nncopy(x2,2,3) 22 | 23 | % Mark Beale, 11-31-97 24 | % Copyright 1992-2002 The MathWorks, Inc. 25 | % $Revision: 1.7 $ 26 | 27 | [r,c] = size(x); 28 | rowInd = rem([0:(r*m-1)],r)+1; 29 | colInd = rem([0:(c*n-1)],c)+1; 30 | y = x(rowInd,colInd); 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/nnt2c.m: -------------------------------------------------------------------------------- 1 | function net = nnt2c(pr,w,klr,clr) 2 | %NNT2C Update NNT 2.0 competitive layer. 3 | % 4 | % Syntax 5 | % 6 | % net = nnt2c(pr,w,klr,clr) 7 | % 8 | % Description 9 | % 10 | % NNT2C(PR,W,KLR,CLR) takes these arguments, 11 | % PR - Rx2 matrix of min and max values for R input elements. 12 | % W - SxR weight matrix. 13 | % KLR - Kohonen learning rate, default = 0.01. 14 | % CLR - Conscience learning rate, default = 0.001. 15 | % and returns a competitive layer. 16 | % 17 | % Once a network has been updated it can be simulated, initialized 18 | % adapted, or trained with SIM, INIT, ADAPT, and TRAIN. 19 | % 20 | % See also NEWC. 21 | 22 | % Mark Beale, 11-31-97 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.8 $ 25 | 26 | % Check 27 | if nargin < 2, error('Not enough input arguments.'), end 28 | if size(pr,1) ~= size(w,2), error('PR and W sizes do not match.'), end 29 | if size(pr,2) ~= 2, error('PR must have two columns.'), end 30 | 31 | % Defaults 32 | if nargin < 3, klr = 0.01; end 33 | if nargin < 4, clr = 0.001; end 34 | 35 | % Update 36 | net = newc(pr,size(w,1),klr,clr); 37 | net.iw{1,1} = w; 38 | net.b{1} = initcon(size(w,1)); 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/nnt2hop.m: -------------------------------------------------------------------------------- 1 | function net = nnt2hop(w,b) 2 | %NNT2HOP Update NNT 2.0 Hopfield recurrent network. 3 | % 4 | % Syntax 5 | % 6 | % net = nnt2p(w,b) 7 | % 8 | % Description 9 | % 10 | % NNT2HOP(W,B) takes these arguments, 11 | % W - SxS weight matrix. 12 | % B - Sx1 bias vector 13 | % and returns a perceptron. 14 | % 15 | % Once a network has been updated it can be simulated, 16 | % initialized, adapted, or trained with SIM, INIT, ADAPT, and TRAIN. 17 | % 18 | % See also NEWHOP. 19 | 20 | % Mark Beale, 11-31-97 21 | % Copyright 1992-2002 The MathWorks, Inc. 22 | % $Revision: 1.8 $ 23 | 24 | % Check 25 | if size(w,1) ~= size(w,2), error('W must be a square matrix.'), end 26 | if size(w,1) ~= size(b,1), error('W and B sizes do not match.'), end 27 | if size(b,2) ~= 1, error('B must have one column.'), end 28 | 29 | % Update 30 | net = network(0,1,1,[],1,1); 31 | net.layers{1}.size = size(w,1); 32 | net.layers{1}.transferFcn = 'satlins'; 33 | net.b{1} = b; 34 | net.lw{1,1} = w; 35 | net.layerWeights{1,1}.delays = 1; 36 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/nnt2lin.m: -------------------------------------------------------------------------------- 1 | function net = nnt2lin(pr,w,b,lr) 2 | %NNT2LIN Update NNT 2.0 linear layer. 3 | % 4 | % Syntax 5 | % 6 | % net = nnt2lin(pr,w,b,lr) 7 | % 8 | % Description 9 | % 10 | % NNT2LIN(PR,W,B) takes these arguments, 11 | % PR - Rx2 matrix of min and max values for R input elements. 12 | % W - SxR weight matrix. 13 | % B - Sx1 bias vector 14 | % LR - Learning rate, default = 0.01; 15 | % and returns a linear layer. 16 | % 17 | % Once a network has been updated it can be simulated, initialized, 18 | % adapted, or trained with SIM, INIT, ADAPT, and TRAIN. 19 | % 20 | % See also NEWLIN. 21 | 22 | % Mark Beale, 11-31-97 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.8 $ 25 | 26 | % Check 27 | if size(pr,1) ~= size(w,2), error('PR and W sizes do not match.'), end 28 | if size(pr,2) ~= 2, error('PR must have two columns.'), end 29 | if size(w,1) ~= size(b,1), error('W and B sizes do not match.'), end 30 | if size(b,2) ~= 1, error('B must have one column.'), end 31 | 32 | % Defaults 33 | if nargin < 4, lr = 0.01; end 34 | 35 | % Update 36 | net = newlin(pr,length(b),[0],lr); 37 | net.iw{1,1} = w; 38 | net.b{1} = b; 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/nntool.m: -------------------------------------------------------------------------------- 1 | function nntool 2 | %NNTOOL Neural Network Toolbox graphical user interface. 3 | % 4 | % Syntax 5 | % 6 | % nntool 7 | % 8 | % Description 9 | % 10 | % NNTOOL opens the Network/Data Manager window which allows 11 | % you to import, create, use, and export neural networks 12 | % and data. 13 | 14 | % Copyright 1992-2002 The MathWorks, Inc. 15 | % $Revision: 1.13 $ $Date: 2002/03/25 16:52:33 $ 16 | 17 | % make sure we are on a platform that has the desktop 18 | jc=javachk('mwt','NNTOOL'); 19 | if ~isempty(jc) 20 | disp(jc) 21 | return 22 | end 23 | 24 | % NNTGUI access port 25 | nntgui = com.mathworks.toolbox.nnet.NNTGUI('dummy'); 26 | 27 | % Open manager 28 | launchNNManager(nntgui); 29 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/normc.m: -------------------------------------------------------------------------------- 1 | function n = normc(m) 2 | %NORMC Normalize columns of a matrix. 3 | % 4 | % Syntax 5 | % 6 | % normc(M) 7 | % 8 | % Description 9 | % 10 | % NORMC(M) normalizes the columns of M to a length of 1. 11 | % 12 | % Examples 13 | % 14 | % m = [1 2; 3 4] 15 | % n = normc(m) 16 | % 17 | % See also NORMR 18 | 19 | % Mark Beale, 1-31-92 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.10 $ $Date: 2002/03/25 16:52:35 $ 22 | 23 | if nargin < 1,error('Not enough input arguments.'); end 24 | 25 | [mr,mc] = size(m); 26 | if (mr == 1) 27 | n = ones(1,mc); 28 | else 29 | n =ones(mr,1)*sqrt(ones./sum(m.*m)).*m; 30 | end 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/normr.m: -------------------------------------------------------------------------------- 1 | function n = normr(m) 2 | %NORMR Normalize rows of a matrix. 3 | % 4 | % Syntax 5 | % 6 | % normr(M) 7 | % 8 | % Description 9 | % 10 | % NORMR(M) normalizes the columns of M to a length of 1. 11 | % 12 | % Examples 13 | % 14 | % m = [1 2; 3 4] 15 | % n = normr(m) 16 | % 17 | % See also NORMC. 18 | 19 | % Mark Beale, 1-31-92 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.10 $ $Date: 2002/03/25 16:52:35 $ 22 | 23 | if nargin < 1,error('Not enough input arguments.'); end 24 | 25 | [mr,mc]=size(m); 26 | if (mc == 1) 27 | n = m ./ abs(m); 28 | else 29 | n=sqrt(ones./(sum((m.*m)')))'*ones(1,mc).*m; 30 | end 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/plotv.m: -------------------------------------------------------------------------------- 1 | function plotv(m,t) 2 | %PLOTV Plot vectors as lines from the origin. 3 | % 4 | % Syntax 5 | % 6 | % plotv(m,t) 7 | % 8 | % Description 9 | % 10 | % PLOTV(M,T) takes two inputs, 11 | % M - RxQ matrix of Q column vectors with R elements. 12 | % T - (optional) the line plotting type, default = '-'. 13 | % and plots the column vectors of M. 14 | % 15 | % R must be 2 or greater. If R is greater than two, 16 | % only the first two rows of M are used for the plot. 17 | % 18 | % Examples 19 | % 20 | % plotv([-.4 0.7 .2; -0.5 .1 0.5],'-') 21 | 22 | % Mark Beale, 1-31-92 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.10 $ $Date: 2002/03/25 16:53:17 $ 25 | 26 | if nargin < 1,error('Wrong number of arguments.');end 27 | 28 | [mr,mc] = size(m); 29 | if mr < 2 30 | error('Matrix must have at least 2 rows.'); 31 | end 32 | 33 | if nargin == 1 34 | t = '-'; 35 | end 36 | 37 | xy0 = zeros(1,mc); 38 | plot([xy0 ;m(1,:)],[xy0 ;m(2,:)],t); 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/pnormc.m: -------------------------------------------------------------------------------- 1 | function n=pnormc(m,r) 2 | %PNORMC Pseudo-normalize columns of a matrix. 3 | % 4 | % Syntax 5 | % 6 | % pnormc(x,r) 7 | % 8 | % Description 9 | % 10 | % PNORMC(M,R) takes these arguments, 11 | % X - MxN matrix. 12 | % R - (optional) radius to normalize columns to, default = 1. 13 | % returns X with an additional row of elements which results 14 | % in new column vector lengths of R. 15 | % 16 | % WARNING: For this function to work properly, the columns of X must 17 | % originally have vector lengths less than R. 18 | % 19 | % Examples 20 | % 21 | % x = [0.1 0.6; 0.3 0.1]; 22 | % y = pnormc(x) 23 | % 24 | % See also NORMC, NORMR. 25 | 26 | % Mark Beale, 1-31-92 27 | % Copyright 1992-2002 The MathWorks, Inc. 28 | % $Revision: 1.10 $ $Date: 2002/03/25 16:53:18 $ 29 | 30 | if nargin < 1,error('Not enough input arguments.'); end 31 | 32 | if nargin == 1 33 | r = 1; 34 | end 35 | 36 | [mr mc] = size(m); 37 | if mr == 1 38 | n = [m sqrt(r.*r-m.*m)]; 39 | else 40 | n = [m; sqrt(r.*r-sum(m.*m))]; 41 | end 42 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/quant.m: -------------------------------------------------------------------------------- 1 | function y = quant(x,q) 2 | %QUANT Discretize values as multiples of a quantity. 3 | % 4 | % Syntax 5 | % 6 | % quant(x,q) 7 | % 8 | % Description 9 | % 10 | % QUANT(X,Q) takes these inputs, 11 | % X - Matrix, vector or scalar. 12 | % Q - Minimum value. 13 | % and returns values in X rounded to nearest multiple of Q 14 | % 15 | % Examples 16 | % 17 | % x = [1.333 4.756 -3.897]; 18 | % y = quant(x,0.1) 19 | 20 | % Mark Beale, 12-15-93 21 | % Copyright 1992-2002 The MathWorks, Inc. 22 | % $Revision: 1.10 $ $Date: 2002/03/25 16:53:19 $ 23 | 24 | y = round(x/q)*q; 25 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/randnc.m: -------------------------------------------------------------------------------- 1 | function w = randnc(s,pr) 2 | %RANDNC Normalized column weight initialization function. 3 | % 4 | % Syntax 5 | % 6 | % W = randnc(S,PR) 7 | % W = randnc(S,R) 8 | % 9 | % Description 10 | % 11 | % RANDNC is a weight initialization function. 12 | % 13 | % RANDNC(S,P) takes these inputs, 14 | % S - Number of rows (neurons). 15 | % PR - Rx2 matrix of input value ranges = [Pmin Pmax]. 16 | % and returns an SxR random matrix with normalized columns. 17 | % 18 | % Can also be called as RANDNC(S,R). 19 | % 20 | % See also RANDNR. 21 | 22 | % Mark Beale, 1-31-92 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.10 $ $Date: 2002/03/25 16:52:12 $ 25 | 26 | if nargin ~= 2, error('Wrong number of arguments.'); end 27 | 28 | if size(pr,2) == 1 29 | r = pr; 30 | else 31 | r = size(pr,1); 32 | end 33 | w = normc(2*rand(s,r)-1); 34 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/randnr.m: -------------------------------------------------------------------------------- 1 | function w = randnr(s,pr) 2 | %RANDNR Normalized row weight initialization function. 3 | % 4 | % Syntax 5 | % 6 | % W = randnr(S,PR) 7 | % W = randnr(S,R) 8 | % 9 | % Description 10 | % 11 | % RANDNR is a weight initialization function. 12 | % 13 | % RANDNR(S,P) takes these inputs, 14 | % S - Number of rows (neurons). 15 | % PR - Rx2 matrix of input value ranges = [Pmin Pmax]. 16 | % and returns an SxR random matrix with normalized rows. 17 | % 18 | % Can also be called as RANDNR(S,R). 19 | % 20 | % See also RANDNC. 21 | 22 | % Mark Beale, 1-31-92 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.10 $ $Date: 2002/03/25 16:52:12 $ 25 | 26 | if nargin ~= 2, error('Wrong number of arguments.'); end 27 | 28 | if size(pr,2) == 1 29 | r = pr; 30 | else 31 | r = size(pr,1); 32 | end 33 | w = normr(rands(s,r)); 34 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/slblocks.m: -------------------------------------------------------------------------------- 1 | function blkStruct = slblocks 2 | %SLBLOCKS Defines the block library for a specific Toolbox or Blockset. 3 | 4 | % Mark Beale, 11-31-97 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.12 $ 7 | 8 | blkStruct.Name = sprintf('Neural\nNetwork\nBlockset'); 9 | blkStruct.OpenFcn = 'neural'; 10 | blkStruct.IsFlat = 0;% Is this library "flat" (i.e. no subsystems)? 11 | 12 | % blkStruct.MaskDisplay = ''; 13 | 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/sumsqr.m: -------------------------------------------------------------------------------- 1 | function s = sumsqr(a) 2 | %SUMSQR Sum squared elements of a matrix. 3 | % 4 | % Synopsis 5 | % 6 | % sumsqr(m) 7 | % 8 | % Description 9 | % 10 | % SUMSQR(M) returns the sum of the squared elements in M. 11 | % 12 | % Examples 13 | % 14 | % s = sumsqr([1 2;3 4]) 15 | 16 | % Mark Beale, 1-31-92 17 | % Copyright 1992-2002 The MathWorks, Inc. 18 | % $Revision: 1.10 $ $Date: 2002/03/25 16:52:35 $ 19 | 20 | if nargin < 1,error('Not enough input arguments.');end 21 | 22 | s = sum(sum(a.*a)); 23 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnet/vec2ind.m: -------------------------------------------------------------------------------- 1 | function i=vec2ind(v) 2 | %VEC2IND Transform vectors to indices. 3 | % 4 | % Syntax 5 | % 6 | % ind = vec2ind(vec) 7 | % 8 | % Description 9 | % 10 | % IND2VEC and VEC2IND allow indices to be represented 11 | % either by themselves or as vectors containing a 1 in the 12 | % row of the index they represent. 13 | % 14 | % VEC2IND(VEC) takes one argument, 15 | % VEC - Matrix of vectors, each containing a single 1. 16 | % and returns the indices of the 1's. 17 | % 18 | % Examples 19 | % 20 | % Here four vectors (containing only one 1 each) are defined 21 | % and the indices of the 1's are found. 22 | % 23 | % vec = [1 0 0 0; 0 0 1 0; 0 1 0 1] 24 | % ind = vec2ind(vec) 25 | % 26 | % See also IND2VEC. 27 | 28 | % Mark Beale, 12-15-93 29 | % Copyright 1992-2002 The MathWorks, Inc. 30 | % $Revision: 1.10 $ $Date: 2002/03/25 16:52:41 $ 31 | 32 | [i,j,s] = find(v); 33 | i=i'; 34 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/alabel.m: -------------------------------------------------------------------------------- 1 | function alabel(x,y,t,z) 2 | %ALABEL Set axis labels and title. 3 | % 4 | % This function is obselete. 5 | % Use XLABEL, YLABEL, TITLE, and AXIS. 6 | 7 | nntobsf('alabel','Use XLABEL, YLABEL, TITLE, and AXIS.') 8 | 9 | % 10 | % *WARNING*: ALABEL is undocumented as it may be altered 11 | % at any time in the future without warning. 12 | 13 | % ALABEL(X,Y,T,Z) 14 | % X - X axis label (string). 15 | % Y - Y axis label (string). 16 | % T - Title of axis (string). 17 | % Z - Z axis label (string). 18 | % Labels current axis with xlabel X, ylabel Y and title T. 19 | % 20 | % ALABEL may be called with from 0 to 3 arguments. 21 | 22 | % Mark Beale, 12-15-93 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:40 $ 25 | 26 | n = nargin; 27 | if n == 0 28 | x = 'Wavelength'; 29 | y = 'Decay rate'; 30 | t = 'Foobar Decay Rates'; 31 | n = 3; 32 | end 33 | 34 | xlabel(x) 35 | if n >= 2, ylabel(y), end 36 | if n >= 3, title(t), end 37 | if n == 4, zlabel(z), end 38 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/appcs1d.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nnobsolete/appcs1d.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/appcs2d.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nnobsolete/appcs2d.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/appcs2d2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/nnet/nnobsolete/appcs2d2.mat -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/assoclr.m: -------------------------------------------------------------------------------- 1 | % Associative learning rules. 2 | % 3 | % Learning rules. 4 | % learnh - Hebb weight learning function. 5 | % learnhd - Hebb with decay weight learning function. 6 | % learnis - Instar weight learning function. 7 | % learnos - Outstar weight learning function. 8 | % learnk - Kohonen weight learning function. 9 | % 10 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 11 | 12 | % Copyright 1992-2002 The MathWorks, Inc. 13 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:35 $ 14 | 15 | help assoclr 16 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/backprop.m: -------------------------------------------------------------------------------- 1 | % Backpropagation networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newff - Create a feed-forward backpropagation network. 7 | % newcf - Create a cascade-forward backpropagation network. 8 | % newfftd - Create a feed-forward input-delay backprop network. 9 | % 10 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 11 | 12 | % Copyright 1992-2002 The MathWorks, Inc. 13 | % $Revision: 1.12 $ $Date: 2002/03/25 16:54:36 $ 14 | 15 | help backprop 16 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/barerr.m: -------------------------------------------------------------------------------- 1 | function barerr(e,t) 2 | %BARERR Plot bar chart of errors. 3 | % 4 | % This function is obselete. 5 | % Use BAR to make bar plots. 6 | 7 | nntobsf('barerr','Use BAR to make bar plots.') 8 | 9 | % 10 | % BARERR(E) 11 | % E - SxQ matrix of error vectors. 12 | % Plots bar chart of the squared errors in each column. 13 | % 14 | % EXAMPLE: e = [1.0 0.0 -0.2 2.0; 0.5 0.0 0.6 -1.0]; 15 | % barerr(e) 16 | % 17 | % See also NNPLOT, ERRSURF, PLOTERR, PLOTES, PLOTEP. 18 | 19 | % Mark Beale, 1-31-92 20 | % Revised 12-15-93, MB 21 | % Copyright 1992-2002 The MathWorks, Inc. 22 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:41 $ 23 | 24 | if nargin < 1, error('Not enough input arguments'),end 25 | if nargin == 2, e = t-e; end 26 | 27 | bar(nnsumc(e .* e)); 28 | title('Network Errors'); 29 | xlabel('Input/Target Pairs') 30 | ylabel('Sum-Squared Error') 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/compnet.m: -------------------------------------------------------------------------------- 1 | % Competitive networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newc - Create a competitive layer. 7 | % 8 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 9 | 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.10 $ $Date: 2002/03/25 16:54:47 $ 12 | 13 | help compnet 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/deltalin.m: -------------------------------------------------------------------------------- 1 | function d = deltalin(a,d,w) 2 | %DELTALIN Delta function for PURELIN neurons. 3 | % 4 | % This function is obselete. 5 | % Use DPURELIN to calculates PURELIN derivatives. 6 | 7 | nntobsf('deltalin','Use DPURELIN to calculates PURELIN derivatives.') 8 | 9 | % 10 | % DELATLIN(A) 11 | % A - S1xQ matrix of output vectors. 12 | % Returns the S1xQ matrix of derivatives of the output vectors 13 | % with respect to the net input of the PURELIN transfer function. 14 | % 15 | % DELTALIN(A,E) 16 | % E - S1xQ matrix of associated errors 17 | % Returns an S1xQ matrix of derivatives of error for an output layer. 18 | % 19 | % DELTALIN(A,D,W) 20 | % D - S2xQ matrix of next layer delta vectors 21 | % W - S2xS1 weight matrix between layers. 22 | % Returns an S1xQ matrix of derivatives of error for a hidden layer. 23 | % 24 | % See also NNTRANS, BACKPROP, PURELIN. 25 | 26 | % Mark Beale, 1-31-92 27 | % Revised 12-15-93, MB 28 | % Copyright 1992-2002 The MathWorks, Inc. 29 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:45 $ 30 | 31 | if nargin == 1 32 | d = ones(size(a)); 33 | elseif nargin == 2 34 | d = d; 35 | else 36 | d = w'*d; 37 | end 38 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/deltatan.m: -------------------------------------------------------------------------------- 1 | function d = deltatan(a,d,w) 2 | %DELTATAN Delta function for TANSIG neurons. 3 | % 4 | % This function is obselete. 5 | % Use DTANSIG to calculates TANSIG derivatives. 6 | 7 | nntobsf('deltatan','Use DTANSIG to calculates TANSIG derivatives.') 8 | 9 | % 10 | % DELTATAN(A,E) 11 | % A - S1xQ matrix of output vectors 12 | % E - S1xQ matrix of associated errors 13 | % Returns an SxQ matrix of output layer derivatives. 14 | % 15 | % DELTATAN(A,D,W) 16 | % D - S2xQ matrix of next layer delta vectors 17 | % W - S2xS1 weight matrix between layers. 18 | % Returns an SxQ matrix of hidden layer derivatives. 19 | % 20 | % DELTATAN(A) 21 | % Returns derivatives of outputs A (not error) for TRAINLM. 22 | % 23 | % See also NNTRANS, BACKPROP, TANSIG, DELTALOG, DELTALIN. 24 | 25 | % Mark Beale, 1-31-92 26 | % Revised 12-15-93, MB 27 | % Copyright 1992-2002 The MathWorks, Inc. 28 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:47 $ 29 | 30 | if nargin < 1,error('Not enough input arguments'),end 31 | 32 | if nargin == 1 33 | d = 1-(a.*a); 34 | elseif nargin == 2 35 | d = (1-(a.*a)).*d; 36 | else 37 | d = (1-(a.*a)).*(w'*d); 38 | end 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/elman.m: -------------------------------------------------------------------------------- 1 | % Elman recurrent networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newelm - New Elman backpropagation network. 7 | % 8 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 9 | 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.13 $ $Date: 2002/03/25 16:54:37 $ 12 | 13 | help elman 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/hopfield.m: -------------------------------------------------------------------------------- 1 | % Hopfield recurrent networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following function: 5 | % 6 | % newhop - Create a Hopfield recurrent network. 7 | % 8 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 9 | 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.14 $ $Date: 2002/03/25 16:54:38 $ 12 | 13 | help hopfield 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/initc.m: -------------------------------------------------------------------------------- 1 | function w = initc(p,s) 2 | %INITC Inititialize competitive layer. 3 | % 4 | % This function is obselete. 5 | % Use NNT2C and INIT to update and initialize your network. 6 | 7 | nntobsf('initc','Use NNT2C and INIT to update and initialize your network.') 8 | 9 | % INITC(P,S) 10 | % P - Rx2 matrix of input vectors. 11 | % S - Number of neurons in layer. 12 | % Returns SxR weight matrix. 13 | % 14 | % IMPORTANT: Each ith row of P must contain expected 15 | % min and max values for the ith input. 16 | % 17 | % EXAMPLE: W = initc([-2 2;0 5],3) 18 | % p = [1 2 3]'; 19 | % a = simuc(p,W) 20 | % 21 | % See also INITFUN, COMPNET, SIMUC, TRAINC. 22 | 23 | % Mark Beale, 12-15-93 24 | % Copyright 1992-2002 The MathWorks, Inc. 25 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:48 $ 26 | 27 | % INPUTS 28 | [R,Q] = size(p); 29 | if Q < 2,error('First argument did not have multiple columns.'),end 30 | 31 | w = midpoint(s,p); 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/initp.m: -------------------------------------------------------------------------------- 1 | function [w,b] = initp(r,s) 2 | %INITP Initialize perceptron layer. 3 | % 4 | % This function is obselete. 5 | % Use NNT2P and INIT to update and initialize your network. 6 | 7 | nntobsf('initp','Use NNT2P and INIT to update and initialize your network.') 8 | 9 | % [W,B] = INITP(R,S) 10 | % R - Number of inputs to layer. 11 | % S - Number of neurons in layer. 12 | % Returns: 13 | % W - SxR Weight matrix. 14 | % B - Bias (column) vector. 15 | % 16 | % [W,B] = INITP(P,T) 17 | % P - RxQ matrix of input vectors. 18 | % T - SxQ matrix of target outputs. 19 | % Returns weights and biases. 20 | % 21 | % EXAMPLE: [w,b] = initp(2,3) 22 | % p = [0.5; -2]; 23 | % a = simup(p,w,b) 24 | % 25 | % See also: NNINIT, PERCEPT, HARDLIM, SIMUP, LEARNP, TRAINP. 26 | 27 | % Mark Beale, 12-15-93 28 | % Copyright 1992-2002 The MathWorks, Inc. 29 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:51 $ 30 | 31 | if nargin < 2,error('Not enough arguments.'),end 32 | 33 | % NUMBER OF INPUTS 34 | [R,Q] = size(r); 35 | if max(R,Q) > 1 36 | r = R; 37 | end 38 | 39 | % NUMBER OF NEURONS 40 | [S,Q] = size(s); 41 | if max(S,Q) > 1 42 | s = S; 43 | end 44 | 45 | [w,b] = rands(s,r); 46 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/initsm.m: -------------------------------------------------------------------------------- 1 | function w = initsm(p,s) 2 | %INITSM Inititialize self-organizing map. 3 | % 4 | % This function is obselete. 5 | % Use NNT2SOM and INIT to update and initialize your network. 6 | 7 | nntobsf('initsm','Use NNT2SOM and INIT to update and initialize your network.') 8 | 9 | % INITSM(P,S) 10 | % P - Rx2 matrix of input vectors. 11 | % S - Number of neurons in layer. 12 | % Returns: 13 | % W - SxR weight matrix. 14 | % 15 | % IMPORTANT: Each ith row of P must contain expected 16 | % min and max values for the ith input. 17 | % 18 | % EXAMPLE: w = initsm([-2 2;0 5],6); 19 | % m = nbgrid(2,3); 20 | % p = [1; 2]; 21 | % a = simusm(p,w,m) 22 | % 23 | % See also NNINIT, SELFORG, SIMUSM, TRAINSM. 24 | 25 | % Mark Beale, 12-15-93 26 | % Copyright 1992-2002 The MathWorks, Inc. 27 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:52 $ 28 | 29 | % INPUTS 30 | [R,Q] = size(p); 31 | if Q < 2,error('Matrix expected as first argument.'),end 32 | 33 | w = midpoint(s,[min(p,[],2) max(p,[],2)]); 34 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/learnbp.m: -------------------------------------------------------------------------------- 1 | function [dw,db] = learnbp(p,d,lr) 2 | %LEARNBP Backpropagation learning rule. 3 | % 4 | % This function is obselete. 5 | % Use LEARNGD to calculate new weights and biases. 6 | 7 | nntobsf('learnbp','Use LEARNGD to calculate new weights and biases.') 8 | 9 | % [dW,dB] = LEARNBP(P,D,LR) 10 | % P - RxQ matrix of input vectors. 11 | % E - SxQ matrix of error vectors. 12 | % LR - the learning rate (default = 1). 13 | % Returns: 14 | % dW - a weight change matrix. 15 | % dB - a bias change vector (optional). 16 | % 17 | % See also NNLEARN, BACKPROP, SIMFF, INITFF, TRAINBP. 18 | 19 | % Mark Beale, 1-31-92 20 | % Revised 12-15-93, MB 21 | % Copyright 1992-2002 The MathWorks, Inc. 22 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:53 $ 23 | 24 | if nargin < 2, error('Not enough arguments.'); end 25 | if nargin == 3, d = lr*d; end 26 | 27 | dw = d*p'; 28 | if nargout == 2 29 | [R,Q] = size(p); 30 | db = d*ones(Q,1); 31 | end 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/learnbpm.m: -------------------------------------------------------------------------------- 1 | function [dw,db] = learnbm(p,d,lr,mc,dw,db) 2 | %LEARNBPM Backpropagation learning rule with momentum. 3 | % 4 | % This function is obselete. 5 | % Use LEARNGDM to calculate new weights and biases. 6 | 7 | nntobsf('learnbpm','Use LEARNGDM to calculate new weights and biases.') 8 | 9 | % [dW,dB] = LEARNBM(P,D,LR,MC,dW,dB) 10 | % P - RxQ matrix of input vectors. 11 | % D - SxQ matrix of error vectors. 12 | % lr - the learning rate. 13 | % mc - momentum constant. 14 | % dW - SxR weight change matrix. 15 | % dB - Sx1 bias change vector (optional). 16 | % Returns: 17 | % dW - a new weight change matrix. 18 | % dB - a new bias change vector (optional). 19 | % 20 | % See also NNLEARN, BACKPROP, SIMFF, INITFF, TRAINBPX. 21 | 22 | % Mark Beale, 1-31-92 23 | % Revised 12-15-93, MB 24 | % Copyright 1992-2002 The MathWorks, Inc. 25 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:54 $ 26 | 27 | if nargin < 5,error('Not enough input arguments'),end 28 | 29 | x = (1-mc)*lr*d; 30 | dw = mc*dw + x*p'; 31 | if nargout == 2 32 | [R,Q] = size(p); 33 | db = mc*db + x*ones(Q,1); 34 | end 35 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/learnlm.m: -------------------------------------------------------------------------------- 1 | function j = learnlm(p,d) 2 | %LEARNLM Levenberg-Marquardt learning rule. 3 | % 4 | % This function is obselete. 5 | % Use NNT2FF and TRAIN to update and train your network. 6 | 7 | nntobsf('learnlm','Use NNT2FF and TRAIN to update and train your network.') 8 | 9 | % LEARNLM(P,D) 10 | % P - RxQ matrix of input (column) vectors. 11 | % D - SxQ matrix of delta (column) vectors. 12 | % Returns: 13 | % Partial jacobian matrix. 14 | % 15 | % See also NNLEARN, BACKPROP, INITFF, SIMFF, TRAINLM. 16 | 17 | % Mark Beale, 12-15-93 18 | % Copyright 1992-2002 The MathWorks, Inc. 19 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:55 $ 20 | 21 | if nargin < 2, error('Wrong number of arguments.'),end 22 | 23 | [R,Q]=size(p); 24 | [S,Q]=size(d); 25 | j = nncpy(d',R) .* nncpyi(p',S); 26 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/learnlvq.m: -------------------------------------------------------------------------------- 1 | function dw = learnlvq2(w,p,a,t,lr) 2 | %LEARNLVQ Learning vector quantization rule. 3 | % 4 | % This function is obselete. 5 | % Use NNT2LVQ and TRAIN to update and train your network. 6 | 7 | nntobsf('learnlvq','Use NNT2LVQ and TRAIN to update and train your network.') 8 | 9 | % LEARNLVQ(W,P,A,T,LR) 10 | % W - SxR weight matrix. 11 | % P - Rx1 input vector. 12 | % A - Sx1 0/1 output vector. 13 | % T - Sx1 0/1 target vector 14 | % LR - Learning rate. 15 | % Returns a weight change matrix. 16 | % 17 | % See also NNLEARN, LVQ, SIMLVQ, INITLVQ, TRAINLVQ. 18 | 19 | % Mark Beale, 12-15-93 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:55 $ 22 | 23 | if nargin < 4,error('Not enough arguments.'); end 24 | 25 | i = find(a ~= 0); 26 | len = length(i); 27 | 28 | [S,R] = size(w); 29 | if len == 1 30 | x = t(i).*2 - 1; 31 | dw = sparse(i,1:R,lr*(p'-w(i,:))*x,S,R,R); 32 | else 33 | dw = zeros(size(w)); 34 | x = t(i).*2 - 1; 35 | dw(i,:) = lr*(ones(len,1)*p'-w(i,:)).*(x * ones(1,R)); 36 | end 37 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/linnet.m: -------------------------------------------------------------------------------- 1 | % Linear networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newlind - Design a linear layer. 7 | % newlin - Create a linear layer. 8 | % 9 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 10 | 11 | % Copyright 1992-2002 The MathWorks, Inc. 12 | % $Revision: 1.13 $ $Date: 2002/03/25 16:54:38 $ 13 | 14 | help linnet 15 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/lvq.m: -------------------------------------------------------------------------------- 1 | % Learning vector quantization. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newlvq - Create a learning vector quantization network. 7 | % 8 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 9 | 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:39 $ 12 | 13 | help lvq 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nncpy.m: -------------------------------------------------------------------------------- 1 | function b = nncpy(m,n) 2 | %NNCPY Make copies of a matrix. 3 | % 4 | % This function is obselete. 5 | % Use NNCOPY. 6 | 7 | nntobsf('nncpy','Use NNCOPY(M,1).') 8 | 9 | % 10 | % *WARNING*: This function is undocumented as it may be altered 11 | % at any time in the future without warning. 12 | 13 | % NNCPY copies matrices directly as appossed to interleaving 14 | % the copies as done by COPYINT. 15 | % 16 | % NNCPY(M,N) 17 | % M - Matrix. 18 | % N - Number of copies to make. 19 | % Returns: 20 | % Matrix = [M M ...] where M appears N times. 21 | % 22 | % EXAMPLE: M = [1 2; 3 4; 5 6]; 23 | % n = 3; 24 | % X = nncpy(M,n) 25 | % 26 | % SEE ALSO: nncpyi, nncpyd 27 | 28 | % Mark Beale, 12-15-93 29 | % Copyright 1992-2002 The MathWorks, Inc. 30 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:59 $ 31 | 32 | [mr,mc] = size(m); 33 | b = zeros(mr,mc*n); 34 | ind = 1:mc; 35 | for i=[0:(n-1)]*mc 36 | b(:,ind+i) = m; 37 | end 38 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nncpyd.m: -------------------------------------------------------------------------------- 1 | function y = nncpyd(x) 2 | %NNCPYD Copy vectors in a matrix onto diagonals. 3 | % 4 | % This function is obselete. 5 | 6 | nntobsf('nncpyd','') 7 | 8 | % *WARNING*: This function is undocumented as it may be altered 9 | % at any time in the future without warning. 10 | 11 | % NNCPYD(X) 12 | % X - NxM Matrix of column vectors. 13 | % Returns Nx(N*M) matrix of M NxN diagonal matrices 14 | % with the columns of X on each diagonal. 15 | % 16 | % EXAMPLE: X = [1 2; 3 4; 5 6]; 17 | % Y = nncpyd(X) 18 | % 19 | % SEE ALSO: nncpy, nncpyi 20 | 21 | % Mark Beale, 12-15-93 22 | % Copyright 1992-2002 The MathWorks, Inc. 23 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:59 $ 24 | 25 | [xr,xc] = size(x); 26 | 27 | y = zeros(xr,xr*xc); 28 | 29 | i = 1:xr; 30 | for j=0:xr:((xc-1)*xr) 31 | y(i+(i+j-1)*xr) = x(i+j); 32 | end 33 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nncpyi.m: -------------------------------------------------------------------------------- 1 | function b = nncpyi(m,n) 2 | %NNCPYI Make interleaved copies of a matrix. 3 | % 4 | % This function is obselete. 5 | 6 | nntobsf('nncpyi','') 7 | 8 | % 9 | % *WARNING*: This function is undocumented as it may be altered 10 | % at any time in the future without warning. 11 | 12 | % NNCPYI(M,N) 13 | % M - Matrix of columns = [C1 C2 ...]. 14 | % N - Number of copies to make. 15 | % Returns: 16 | % Matrix = [C1 C1 ... C1 C2 C2 ... C2 ... ] 17 | % where each column in M appears N times. 18 | % 19 | % EXAMPLE: M = [1 2; 3 4; 5 6]; 20 | % n = 3; 21 | % X = nncpyi(M,n) 22 | % 23 | % SEE ALSO: nncpy, nncpyd 24 | 25 | % Mark Beale, 12-15-93 26 | % Copyright 1992-2002 The MathWorks, Inc. 27 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:00 $ 28 | 29 | [mr,mc] = size(m); 30 | b = zeros(mr*n,mc); 31 | ind = 1:mr; 32 | for i=[0:(n-1)]*mr 33 | b(ind+i,:) = m; 34 | end 35 | b = reshape(b,mr,n*mc); 36 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nndef.m: -------------------------------------------------------------------------------- 1 | function y=nndef(x,d) 2 | %NNDEF Replace missing and NaN values with defaults. 3 | % 4 | % This function is obselete. 5 | 6 | nntobsf('trainwb','Use TRAINB to train your network.') 7 | 8 | 9 | % NNDEF(X,D) 10 | % X - Row vector of proposed values. 11 | % D - Row vector of default values. 12 | % Returns X with all non-finite and missing values with 13 | % the corresponding values in D. 14 | % 15 | % EXAMPLE: x = [1 2 NaN 4 5]; 16 | % d = [10 20 30 40 50 60]; 17 | % y = nndef(x,d) 18 | 19 | % Mark Beale, 12-15-93 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.14 $ $Date: 2002/03/25 16:54:01 $ 22 | 23 | y = d; 24 | % i = find(finite(x(1:min(length(x),length(y))))); 25 | % %%%%%%%%%%%%%%%%%%%%% use the fllowing line to replace -- fansy 26 | % 2014/12/29 27 | i = find(isfinite(x(1:min(length(x),length(y))))); 28 | y(i) = x(i); 29 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nnfmc.m: -------------------------------------------------------------------------------- 1 | function i = nnfmc(m) 2 | %NNFMC Find largest column vector in matrix. 3 | % 4 | % This function is obselete. 5 | % Use FIND(SUM(M .^ 2) == MAX(SUM(M .^ 2))) instead. 6 | 7 | nntobsf('nnfmc','Use FIND(SUM(M .^ 2) == MAX(SUM(M .^ 2))) instead.') 8 | 9 | % NNFMC(M) 10 | % M - Matrix of columns: [C1 C2 ... Cn] 11 | % Returns index i of the largest vector Ci. 12 | % 13 | % EXAMPLE: M = [1 3 5; 2 4 -10]; 14 | % index = nnfmc(M) 15 | 16 | % Mark Beale, 12-15-93 17 | % Copyright 1992-2002 The MathWorks, Inc. 18 | % $Revision: 1.6 $ $Date: 2002/03/25 16:54:32 $ 19 | 20 | replace = find(isnan(m)); 21 | m(replace) = zeros(size(replace)); 22 | 23 | [mr,mc] = size(m); 24 | 25 | if mr > 1 26 | m = sum(m .^ 2); 27 | end 28 | 29 | i = find(m == max(m)); 30 | i = i(1); 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nnmaxr.m: -------------------------------------------------------------------------------- 1 | function m = nnmaxr(m) 2 | %NNMAXR Find maximum of each row. 3 | % 4 | % This function is obselete. 5 | % Use MAX(M,[],1). 6 | 7 | nntobsf('nnmaxr','Use MAX(M,[],1).') 8 | 9 | % 10 | % *WARNING*: This function is undocumented as it may be altered 11 | % at any time in the future without warning. 12 | 13 | % NNMAXR(M) 14 | % M - Matrix. 15 | % Returns column of maximum row values. 16 | % 17 | % EXAMPLE: M = [1 2 3; 4 5 2] 18 | % maxrow(M) 19 | % 20 | % SEE ALSO: nnmaxr 21 | 22 | % Mark Beale, 12-15-93 23 | % Copyright 1992-2002 The MathWorks, Inc. 24 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:01 $ 25 | 26 | [N,M] = size(m); 27 | 28 | if M > 1 29 | m = max(m')'; 30 | end 31 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nnminr.m: -------------------------------------------------------------------------------- 1 | function m = nnminr(m) 2 | %NNMINR Find minimum of each row. 3 | % 4 | % This function is obselete. 5 | % Use MIN(M,[],1). 6 | 7 | nntobsf('nnminr','Use MIN(M,[],1).') 8 | 9 | % NNMINR(M) 10 | % M - matrix. 11 | % Returns column of minimum row values. 12 | % 13 | % EXAMPLE: M = [1 2 3; 4 5 2] 14 | % nnminr(M) 15 | % 16 | % SEE ALSO: nnmaxr 17 | 18 | % Mark Beale, 12-15-93 19 | % Copyright 1992-2002 The MathWorks, Inc. 20 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:02 $ 21 | 22 | [N,M] = size(m); 23 | 24 | if M > 1 25 | m = min(m')'; 26 | end 27 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/nnsumr.m: -------------------------------------------------------------------------------- 1 | function x = nnsumr(x) 2 | %NNSUMR Sums each row of a matrix. 3 | % 4 | % This function is obselete. 5 | % Use SUM(M,1). 6 | 7 | nntobsf('nnsumr','Use SUM(M,1).') 8 | 9 | % 10 | % *WARNING*: This function is undocumented as it may be altered 11 | % at any time in the future without warning. 12 | 13 | % NNSUMR(X) 14 | % X - Matrix of column vectors: [C1 C2 ... CN]. 15 | % Returns sum of each column. 16 | % 17 | % SUMROW differs from SUM by leaving column vectors unchanged. 18 | % 19 | % EXAMPLE: x = rands(4,5) 20 | % y = nnsumr(x) 21 | % 22 | % SEE ALSO: nnsumc 23 | 24 | % Mark Beale, 12-15-93 25 | % Copyright 1992-2002 The MathWorks, Inc. 26 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:03 $ 27 | 28 | [xr,xc] = size(x); 29 | if xc > 1 30 | x = sum(x')'; 31 | end 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/percept.m: -------------------------------------------------------------------------------- 1 | % Perceptrons. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newp - Create a perceptron. 7 | % 8 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 9 | 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.12 $ $Date: 2002/03/25 16:54:40 $ 12 | 13 | help percept 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/pickic.m: -------------------------------------------------------------------------------- 1 | function k = pickic(n) 2 | %PICKIC Pick initial conditions. 3 | % 4 | % This function is obselete. 5 | 6 | nntobsf('barerr','Use BAR to make bar plots.') 7 | 8 | % *WARNING*: PICKIC is undocumented as it may be altered 9 | % at any time in the future without warning. 10 | 11 | % Mark Beale, 12-15-93 12 | % Copyright 1992-2002 The MathWorks, Inc. 13 | % $Revision: 1.13 $ $Date: 2002/03/25 16:53:42 $ 14 | 15 | if nargin == 0, n = 0; end 16 | 17 | k = 0; 18 | 19 | if n == 0 20 | while (k ~= 1 & k ~= 2) 21 | disp('Would you like to use the weights & biases from:') 22 | disp(' ') 23 | disp(' (1) the code above?') 24 | disp(' (2) the User''s Guide?') 25 | k = input('What do you choose? '); 26 | end 27 | 28 | elseif n == 1 29 | while (k ~= 1 & k ~= 2 & k ~= 3) 30 | disp('Would you like to use the weights & biases:') 31 | disp(' ') 32 | disp(' (1) from the code above?') 33 | disp(' (2) from the User''s Guide?') 34 | disp(' (3) from the Error Contour using the mouse?') 35 | k = input('What do you choose? '); 36 | end 37 | end 38 | 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/plotfa.m: -------------------------------------------------------------------------------- 1 | function h = plotfa(p1,t,p2,a) 2 | %PLOTFA Plot data points and network function approximation. 3 | % 4 | % This function is obselete. 5 | 6 | nntobsf('barerr','Use BAR to make bar plots.') 7 | 8 | % PLOTFA(P1,T,P2,A) 9 | % P1 - 1xQ1 vector of input values. 10 | % T - 1xQ1 vector of targets associated with P1. 11 | % P2 - 1xQ2 vector of input values. 12 | % A - 1xQ2 vector of network outputs associated with P2. 13 | % Plots T with respect to P1 with yellow '+' markers. 14 | % Plots A with respect to P2 with solid magenta line. 15 | 16 | % Mark Beale, 1-31-92. 17 | % Revised 12-15-93, MB. 18 | % Copyright 1992-2002 The MathWorks, Inc. 19 | % $Revision: 1.12 $ 20 | 21 | if nargin < 4, error('Not enough arguments.'); end 22 | 23 | hold off; 24 | plot(p1,t,'+'); 25 | hold on; 26 | if nargout 27 | h = plot(p2,a,'m'); 28 | else 29 | plot(p2,a,'m'); 30 | end 31 | title('Function Approximation') 32 | xlabel('Input') 33 | ylabel('Output: -, Target: +') 34 | drawnow 35 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/plotlr.m: -------------------------------------------------------------------------------- 1 | function plotlr(lr,t) 2 | %PLOTLR Plot network learning rate vs epochs. 3 | % 4 | % This function is obselete. 5 | 6 | nntobsf('barerr','Use BAR to make bar plots.') 7 | 8 | % PLOTLR(LR,T) 9 | % LR - row vector of network learning rates. 10 | % The first value is associated with 11 | % epoch 0, the second with epoch 1, etc. 12 | % T - (Optional) String for graph title. 13 | % Default is 'Network Learning Rate'. 14 | 15 | % Mark Beale, 1-31-92 16 | % Copyright 1992-2002 The MathWorks, Inc. 17 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:07 $ 18 | 19 | if nargin > 2 | nargin < 1 20 | error('Wrong number of arguments.'); 21 | end 22 | 23 | plot(0:length(lr)-1,lr); 24 | xlabel('Epoch') 25 | ylabel('Learning Rate') 26 | 27 | if nargin == 1 28 | title('Network Learning Rate') 29 | else 30 | title(t) 31 | end 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/radbasis.m: -------------------------------------------------------------------------------- 1 | % Radial basis networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % newrb - Design a radial basis network. 7 | % newrbe - Design an exact radial basis network. 8 | % newgrnn - Design a generalized regression neural network. 9 | % newpnn - Design a probabilistic neural network. 10 | % 11 | % Type DEMOS or HELP NNDEMOS for a list of demonstrations. 12 | 13 | % Copyright 1992-2002 The MathWorks, Inc. 14 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:41 $ 15 | 16 | help radbasis 17 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/selforg.m: -------------------------------------------------------------------------------- 1 | % Self-organizing networks. 2 | % 3 | % For information on these networks and the 4 | % functions they use, see the following functions: 5 | % 6 | % New networks. 7 | % newc - Create a competitive layer. 8 | % newsom - Create a self-organizing map. 9 | 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.12 $ $Date: 2002/03/25 16:54:41 $ 12 | 13 | help selforg 14 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/simuc.m: -------------------------------------------------------------------------------- 1 | function a = simuc(p,w,b) 2 | %SIMUC Simulate competitive layer. 3 | % 4 | % This function is obselete. 5 | % Use NNT2C and SIM to update and simulate your network. 6 | 7 | nntobsf('simuc','Use NNT2C and SIM to update and simulate your network.') 8 | 9 | % SIMUC(P,W) 10 | % P - RxQ matrix of input (column) vectors. 11 | % W - SxR weight matrix. 12 | % Returns outputs of the competitive layer. 13 | % 14 | % SIMUC(P,W,B) 15 | % B - Sx1 bias vector. 16 | % Returns outputs of the competitive layer using biases. 17 | % 18 | % EXAMPLE: w = initc([0 1;-5 5],3); 19 | % p = [2; -3]; 20 | % a = simuc(p,w) 21 | % 22 | % See also NNSIM, COMPNET, INITC, TRAINC. 23 | 24 | % Mark Beale, 12-15-93 25 | % Copyright 1992-2002 The MathWorks, Inc. 26 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:10 $ 27 | 28 | if nargin < 2,error('Not enough arguments.'),end 29 | 30 | if nargin == 2 31 | a = compet(-dist(w,p)); 32 | else 33 | a = compet(-dist(w,p),b); 34 | end 35 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/simulin.m: -------------------------------------------------------------------------------- 1 | function a = simulin(p,w,b) 2 | %SIMULIN Simulate linear layer. 3 | % 4 | % This function is obselete. 5 | % Use NNT2LIN and SIM to update and simulate your network. 6 | 7 | nntobsf('simulin','Use NNT2LIN and SIM to update and simulate your network.') 8 | 9 | % SIMULIN(P,W,B) 10 | % P - RxQ Matrix of input (column) vectors. 11 | % W - SxR Weight matrix of the layer. 12 | % B - Sx1 Bias (column) vector of the layer. 13 | % Returns outputs of the perceptron layer. 14 | % 15 | % EXAMPLE: [w,b] = initlin(2,3); 16 | % p = [2; -3]; 17 | % a = simulin(p,w,b) 18 | % 19 | % See also NNSIM, LINNET, SOLVELIN, INITLIN, LEARNWH, ADAPTWH, TRAINWH. 20 | 21 | % Mark Beale, 12-15-93 22 | % Copyright 1992-2002 The MathWorks, Inc. 23 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:13 $ 24 | 25 | if nargin < 2,error('Not enough arguments'), end 26 | 27 | if nargin == 2 28 | a = purelin(w*p); 29 | else 30 | a = purelin(w*p,b); 31 | end 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/simup.m: -------------------------------------------------------------------------------- 1 | function a = simup(p,w,b) 2 | %SIMUP Simulate perceptron layer. 3 | % 4 | % This function is obselete. 5 | % Use NNT2P and SIM to update and simulate your network. 6 | 7 | nntobsf('simup','Use NNT2P and SIM to update and simulate your network.') 8 | 9 | % SIMUP(P,W,B) 10 | % P - RxQ matrix of input (column) vectors. 11 | % W - SxR weight matrix. 12 | % B - Sx1 bias (column) vector. 13 | % Returns outputs of the perceptron layer. 14 | % 15 | % EXAMPLE: [w,b] = initp([0 1;-5 5],3); 16 | % p = [2; -3]; 17 | % a = simup(p,w,b) 18 | % 19 | % See also NNSIM, PERCEPT, HARDLIM, INITP, LEARNP, TRAINP 20 | 21 | % Mark Beale, 12-15-93 22 | % Copyright 1992-2002 The MathWorks, Inc. 23 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:14 $ 24 | 25 | if nargin < 2,error('Not enough arguments.'),end 26 | 27 | a = hardlim(w*p,b); 28 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/simusm.m: -------------------------------------------------------------------------------- 1 | function a = simusm(p,w,m,n) 2 | %SIMUSM Simulates a self-organizing map. 3 | % 4 | % This function is obselete. 5 | % Use NNT2SOM and SIM to update and simulate your network. 6 | 7 | nntobsf('simusm','Use NNT2SOM and SIM to update and simulate your network.') 8 | 9 | % SIMUSM(P,W,B,M,N) 10 | % P - RxQ matrix of input (column) vectors. 11 | % W - SxR weight matrix. 12 | % M - Neighborhood matrix. 13 | % N - Neighborhood size, default = 1. 14 | % Returns outputs of the self-organizing map. 15 | % 16 | % EXAMPLE: w = initsm([-2 2;0 5],6); 17 | % m = nbman(2,3); 18 | % p = [1; 2]; 19 | % a = simusm(p,w,m) 20 | % 21 | % See also NNSIM, SELFORG, INITSM, TRAINSM. 22 | 23 | % Mark Beale, 12-15-93 24 | % Copyright 1992-2002 The MathWorks, Inc. 25 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:16 $ 26 | 27 | if nargin < 3,error('Not enough arguments.'),end 28 | if nargin ==3, n = 1; end 29 | 30 | a = compet(-dist(w,p)); 31 | a = 0.5*(a + sparse(m <= n)*a); 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/solvelin.m: -------------------------------------------------------------------------------- 1 | function [w,b] = solvelin(p,t) 2 | %SOLVELIN Design linear network paramters. 3 | % 4 | % This function is obselete. 5 | % Use NEWLIND to design your network. 6 | 7 | nntobsf('solvelin','Use NEWLIND to design your network.') 8 | 9 | % [W,B] = SOLVELIN(P,T) 10 | % P - RxQ matrix of Q input vectors. 11 | % T - SxQ matrix of Q target vectors. 12 | % Returns: 13 | % W - SxR weight matrix. 14 | % B - Sx1 bias vector. 15 | % 16 | % SOLVELIN(P,T) 17 | % Returns SxR weight matrix for network without biases. 18 | % 19 | % See also NNSOLVE, LINNET, SIMLIN, INITLIN, LEARNWH, ADAPTWH, TRAINWH. 20 | 21 | % Mark Beale, 1-31-92 22 | % Copyright 1992-2002 The MathWorks, Inc. 23 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:17 $ 24 | 25 | if nargin < 2,error('Not enough arguments.'),end 26 | 27 | if nargout <= 1 28 | w= t/p; 29 | else 30 | [pr,pc] = size(p); 31 | x = t/[p; ones(1,pc)]; 32 | w = x(:,1:pr); 33 | b = x(:,pr+1); 34 | end 35 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnobsolete/solverbe.m: -------------------------------------------------------------------------------- 1 | function [w1,b1,w2,b2] = solverbe(p,t,z) 2 | %SOLVERBE Design exact radial basis network. 3 | % 4 | % This function is obselete. 5 | % Use NEWRBE to design your network. 6 | 7 | nntobsf('solverbe','Use NEWRBE to design your network.') 8 | 9 | % [W1,B1,W2,B2] = SOLVERBE(P,T,Z) 10 | % P - RxQ matrix of Q input vectors. 11 | % T - SxQ matrix of Q target vectors. 12 | % Z - Spread of radial basis functions (default = 1). 13 | % Returns: 14 | % W1 - S1xR weight matrix for radial basis layer. 15 | % B1 - S1x1 bias vector for radial basis layer. 16 | % W2 - S2xS1 weight matrix for linear layer. 17 | % B2 - S2x1 bias vector for linear layer. 18 | % 19 | % SOLVERBE creates a radial basis network which performs 20 | % an exact mapping of input to outputs with as many 21 | % hidden neurons as their are input vectors in P. 22 | % 23 | % See also NNSOLVE, RADBASIS, SIMRB, SOLVERB 24 | 25 | % Mark Beale, 12-15-93 26 | % Copyright 1992-2002 The MathWorks, Inc. 27 | % $Revision: 1.11 $ $Date: 2002/03/25 16:53:44 $ 28 | 29 | [r,q] = size(p); 30 | [s2,q] = size(t); 31 | 32 | w1 = p'; 33 | b1 = ones(q,1)*sqrt(-log(.5))/z; 34 | a1 = radbas(dist(w1,p),b1); 35 | [w2,b2] = solvelin(a1,t); 36 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/addnntemppath.m: -------------------------------------------------------------------------------- 1 | function addnntemppath 2 | %ADDNNTEMPPATH Add NNT temporary directory to path. 3 | 4 | % $Revision: 1.2 $ $Date: 2002/03/25 16:55:11 $ 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | 7 | %persistent done 8 | %if isempty(done) 9 | nntempdir=fullfile(tempdir,'matlab_nnet'); 10 | if ~exist(nntempdir,'dir') 11 | mkdir(tempdir,'matlab_nnet') 12 | end 13 | if isempty(findstr(path,nntempdir)) 14 | path(path,nntempdir); 15 | end 16 | % done=1; 17 | %end 18 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/calcerr.m: -------------------------------------------------------------------------------- 1 | function d=calcerr(a,b) 2 | %CALCERR Calculates matrix or cell array errors. 3 | % 4 | % E = CALCERR(T,A) 5 | % T - MxN matrix. 6 | % A - MxN matrix. 7 | % Returns 8 | % D - MxN matrix A-B. 9 | % 10 | % E = CALCERR(A,B) 11 | % T - MxN cell array of matrices A{i,j}. 12 | % A - MxN cell array of matrices B{i,j}. 13 | % Returns 14 | % D - MxN cell array of matrices A{i,j}-B{i,j}. 15 | 16 | % Mark Beale, 11-31-97 17 | % Copyright 1992-2002 The MathWorks, Inc. 18 | % $Revision: 1.8 $ $Date: 2002/03/25 16:54:54 $ 19 | 20 | if isa(a,'double') & isa(b,'double') 21 | 22 | d = a-b; 23 | 24 | elseif isa(a,'cell') & isa(b,'cell') 25 | 26 | [m,n] = size(a); 27 | d = cell(m,n); 28 | for i=1:m 29 | for j=1:n 30 | d{i,j} = a{i,j}-b{i,j}; 31 | end 32 | end 33 | 34 | else 35 | 36 | error('Inputs must both be matrices or both be cell-arrays') 37 | 38 | end 39 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/cliptr.m: -------------------------------------------------------------------------------- 1 | function tr=cliptr(tr,epochs) 2 | %CLIPTR Clip training record to the final number of epochs. 3 | % 4 | % Syntax 5 | % 6 | % tr = cliptr(tr,epochs) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code which calls this function. 13 | 14 | % Mark Beale, 11-31-97 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.7 $ 17 | 18 | indices = 1:(epochs+1); 19 | names = fieldnames(tr); 20 | for i=1:length(names) 21 | name = names{i}; 22 | eval(['tr.' name ' = tr.' name '(:,indices);']); 23 | end 24 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/competsl.m: -------------------------------------------------------------------------------- 1 | function a = competsl(n) 2 | %COMPETSL Competitive transfer function used by SIMULINK. 3 | % 4 | % Syntax 5 | % 6 | % a = competsl(n) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code which calls this function. 13 | 14 | % Mark Beale, 11-31-97 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.7 $ 17 | 18 | [maxn,indn] = max(n,[],1); 19 | a = zeros(size(n)); 20 | a(indn) = 1; 21 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/dnullpf.m: -------------------------------------------------------------------------------- 1 | function d = dnullpf(code,e,x,perf,pp) 2 | %DNULLPF Derivative of null performance function. 3 | % 4 | % DNULLPF('E',E,X,PERF) 5 | % E - Layer errors. 6 | % X - Vector of weight and bias values. 7 | % Returns zeros. 8 | % 9 | % DNULLPF('X',E,X,PERF) 10 | % Returns zeros. 11 | 12 | % Mark Beale, 11-31-97 13 | % Copyright 1992-2002 The MathWorks, Inc. 14 | % $Revision: 1.7 $ 15 | 16 | switch lower(code) 17 | case 'e', 18 | [rows,cols] = size(e); 19 | d = cell(rows,cols); 20 | for i=1:rows 21 | for j=1:cols 22 | d{i,j} = zeros(size(e{i,j})); 23 | end 24 | end 25 | 26 | case 'x', 27 | d = zeros(size(x)); 28 | 29 | otherwise, 30 | error(['Unrecognized code.']) 31 | end 32 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/dnulltf.m: -------------------------------------------------------------------------------- 1 | function d=dnulltf(n,a) 2 | %DNULLTF Null transfer derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dA_dN = dnulltf(N,A) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code which calls this function. 13 | 14 | % Mark Beale, 11-31-97 15 | % Copyright 1992-2002 The MathWorks, Inc. 16 | % $Revision: 1.8 $ 17 | 18 | d = zeros(size(a)); 19 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/dnullwf.m: -------------------------------------------------------------------------------- 1 | function d=dnullwf(code,w,p,z) 2 | %DNULLWF Null weight derivative function. 3 | % 4 | % Syntax 5 | % 6 | % dZ_dP = dnullwf('p',W,P,Z) 7 | % dZ_dW = dnullwf('w',W,P,Z) 8 | % 9 | % Warning!! 10 | % 11 | % This function may be altered or removed in future 12 | % releases of the Neural Network Toolbox. We recommend 13 | % you do not write code which calls this function. 14 | 15 | % Mark Beale, 11-31-97 16 | % Copyright 1992-2002 The MathWorks, Inc. 17 | % $Revision: 1.8 $ 18 | 19 | switch code 20 | case 'p', d = zeros(size(w)); 21 | case 'w', d = zeros(size(p)); 22 | otherwise, error(['Unrecognized code.']) 23 | end 24 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/formgx.m: -------------------------------------------------------------------------------- 1 | function gX = formgx(net,gB,gIW,gLW) 2 | %FORMGX Form bias and weights into single vector. 3 | % 4 | % Syntax 5 | % 6 | % gX = formgx(net,gB,gIW,gLW) 7 | % 8 | % Warning!! 9 | % 10 | % This function may be altered or removed in future 11 | % releases of the Neural Network Toolbox. We recommend 12 | % you do not write code which calls this function. 13 | % 14 | % See also GETX, SETX. 15 | 16 | % Mark Beale, 11-31-97 17 | % Copyright 1992-2002 The MathWorks, Inc. 18 | % $Revision: 1.7 $ 19 | 20 | % Shortcuts 21 | inputLearn = net.hint.inputLearn; 22 | layerLearn = net.hint.layerLearn; 23 | biasLearn = net.hint.biasLearn; 24 | inputWeightInd = net.hint.inputWeightInd; 25 | layerWeightInd = net.hint.layerWeightInd; 26 | biasInd = net.hint.biasInd; 27 | 28 | gX = zeros(net.hint.xLen,1); 29 | for i=1:net.numLayers 30 | for j=find(inputLearn(i,:)) 31 | gX(inputWeightInd{i,j}) = gIW{i,j}(:); 32 | end 33 | for j=find(layerLearn(i,:)) 34 | gX(layerWeightInd{i,j}) = gLW{i,j}(:); 35 | end 36 | if biasLearn(i) 37 | gX(biasInd{i}) = gB{i}(:); 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/newnet.m: -------------------------------------------------------------------------------- 1 | function n = newnet(type) 2 | %NEWNET Notice regarding GUI. 3 | 4 | % Mark Beale, 08-21-00 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | % $Revision: 1.3 $ $Date: 2002/03/25 16:55:11 $ 7 | 8 | n = []; 9 | disp(' ') 10 | disp('To create a neural network using a graphical user interface:') 11 | disp('1. Use the command "nntool" to open the Neural Network Manager.') 12 | disp('2. Click "New Network" to open the dialog for creating networks.') 13 | disp('You can then import or define data and train your network in the GUI') 14 | disp('or export your network to the command line for training.') 15 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/newnntempfile.m: -------------------------------------------------------------------------------- 1 | function [filename,name]=newnntempfile; 2 | %NEWNNTEMPFILE Get new NNT temporary filename. 3 | 4 | % $Revision: 1.2 $ $Date: 2002/03/25 16:55:11 $ 5 | % Copyright 1992-2002 The MathWorks, Inc. 6 | 7 | [p,name] = fileparts(tempname); 8 | filename=fullfile(p,'matlab_nnet',[name '.m']); -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/newtr.m: -------------------------------------------------------------------------------- 1 | function tr=newtr(epochs,varargin) 2 | %NEWTR New training record with any number of optional fields. 3 | % 4 | % Syntax 5 | % 6 | % tr = newtr(epochs,'fieldname1','fieldname2',...) 7 | % tr = newtr([firstEpoch epochs],'fieldname1','fieldname2',...) 8 | % 9 | % Warning!! 10 | % 11 | % This function may be altered or removed in future 12 | % releases of the Neural Network Toolbox. We recommend 13 | % you do not write code which calls this function. 14 | 15 | % Mark Beale, 11-31-97 16 | % Copyright 1992-2002 The MathWorks, Inc. 17 | % $Revision: 1.9 $ $Date: 2002/03/25 16:55:00 $ 18 | 19 | if nargin < 1,error('Not enough input arguments.'),end 20 | 21 | names = varargin; 22 | tr.epoch = 0:epochs; 23 | blank = zeros(1,epochs+1)+NaN; 24 | for i=1:length(names) 25 | eval(['tr.' names{i} '=blank;']); 26 | end 27 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/nntobsf.m: -------------------------------------------------------------------------------- 1 | function nntobsf(fcn,varargin) 2 | %NNTOBSF Warn that a function is obsolete. 3 | % 4 | % nntobsf(fcnName,line1,line2,...) 5 | % 6 | % *WARNING*: This function is undocumented as it may be altered 7 | % at any time in the future without warning. 8 | 9 | % Mark Beale, 11-31-97 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.7 $ 12 | 13 | global NNTWARNFLAG; 14 | if isempty(NNTWARNFLAG) 15 | disp(' ') 16 | disp(['*WARNING* ' upper(fcn) ' is an obsolete function.']) 17 | for i=1:length(varargin) 18 | disp([' ' varargin{i}]) 19 | end 20 | disp([' Type NNTWARN OFF to suppress NNT warning messages.']) 21 | disp(' ') 22 | elseif strcmp(NNTWARNFLAG,'error') 23 | error([upper(fcn) ' is an obsolete function.']) 24 | end 25 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/nntobsu.m: -------------------------------------------------------------------------------- 1 | function nntobsu(fcn,varargin) 2 | %NNTOBSU Warn that a function use is obsolete. 3 | % 4 | % nntobsu(fcnName,line1,line2,...) 5 | % 6 | % *WARNING*: This function is undocumented as it may be altered 7 | % at any time in the future without warning. 8 | 9 | % Mark Beale, 11-31-97 10 | % Copyright 1992-2002 The MathWorks, Inc. 11 | % $Revision: 1.7 $ 12 | 13 | global NNTWARNFLAG; 14 | if isempty(NNTWARNFLAG) 15 | disp(' ') 16 | disp(['*WARNING* ' upper(fcn) ' used in an obsolete way.']) 17 | for i=1:length(varargin) 18 | disp([' ' varargin{i}]) 19 | end 20 | disp([' Type NNTWARN OFF to suppress NNT warning messages.']) 21 | disp(' ') 22 | elseif strcmp(NNTWARNFLAG,'error') 23 | error([upper(fcn) ' is used in an obsolete way.']) 24 | end 25 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/nntwarn.m: -------------------------------------------------------------------------------- 1 | function nntwarn(cmd) 2 | %NNTWARN 3 | % 4 | % Syntax 5 | % 6 | % nntwarn on 7 | % nntwarn off 8 | % 9 | % Description 10 | % 11 | % NNTWARN allows Neural Network Toolbox warnings to be temporarily 12 | % turned off. 13 | % 14 | % Code using obsolete Neural Network Toolbox functionality can 15 | % generate a lot of warnings. This function allows you to skip 16 | % those warnings. However, we encourage you to update your code 17 | % to ensure that it will run under future versions of the toolbox. 18 | 19 | % Mark Beale, 11-31-97 20 | % Copyright 1992-2002 The MathWorks, Inc. 21 | % $Revision: 1.8 $ 22 | 23 | if nargin < 1, error('Not enough input arguments.'),end 24 | 25 | global NNTWARNFLAG; 26 | 27 | switch(lower(cmd)) 28 | case 'on' 29 | NNTWARNFLAG = []; 30 | case 'off' 31 | NNTWARNFLAG = 'off'; 32 | case 'error' 33 | NNTWARNFLAG = 'error'; 34 | otherwise 35 | error('Unrecognized command.') 36 | end 37 | 38 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/nullpf.m: -------------------------------------------------------------------------------- 1 | function perf=nullpf(e,x,pp) 2 | %NULLPF Null performance function. 3 | % 4 | % Syntax 5 | % 6 | % perf = nullpf(e,x,pp) 7 | % perf = nullpf(e,net,pp) 8 | % info = nullpf(code) 9 | % 10 | % Warning!! 11 | % 12 | % This function may be altered or removed in future 13 | % releases of the Neural Network Toolbox. We recommend 14 | % you do not write code which calls this function. 15 | 16 | % Mark Beale, 11-31-97 17 | % Copyright 1992-2002 The MathWorks, Inc. 18 | % $Revision: 1.8 $ 19 | 20 | if nargin < 1, error('Not enough input arguments.'), end 21 | 22 | % FUNCTION INFO 23 | % ============= 24 | 25 | if isstr(e) 26 | switch e 27 | case 'deriv', 28 | perf = 'dnullpf'; 29 | case 'name', 30 | perf = 'Null'; 31 | case 'pnames', 32 | perf = {}; 33 | case 'pdefaults', 34 | perf = []; 35 | otherwise, 36 | error('Unrecognized code.') 37 | end 38 | return 39 | end 40 | 41 | % CALCULATION 42 | % =========== 43 | 44 | perf = NaN; 45 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/pause2.m: -------------------------------------------------------------------------------- 1 | function pause2(n) 2 | %PAUSE2 Pause procedure for specified time. 3 | % 4 | % PAUSE2(N) 5 | % N - number of seconds (may be fractional). 6 | % Stops procedure for N seconds. 7 | % 8 | % PAUSE2 differs from PAUSE in that pauses may take a fractional 9 | % number of seconds. PAUSE(1.2) will halt a procedure for 1 second. 10 | % PAUSE2(1.2) will halt a procedure for 1.2 seconds. 11 | 12 | % Mark Beale, 1-31-92 13 | % Copyright 1992-2002 The MathWorks, Inc. 14 | % $Revision: 1.11 $ $Date: 2002/03/25 16:54:50 $ 15 | 16 | if nargin ~= 1 17 | error('Wrong number of input arguments.'); 18 | end 19 | 20 | drawnow 21 | t1 = clock; 22 | while etime(clock,t1) < n,end; 23 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/private/nncell2string.m: -------------------------------------------------------------------------------- 1 | %========================================== 2 | function s = nncelltostring(c) 3 | 4 | % Copyright 1992-2002 The MathWorks, Inc. 5 | % $Revision: 1.5 $ $Date: 2002/03/25 16:55:02 $ 6 | 7 | 8 | [rows,cols] = size(c); 9 | s = '{'; 10 | for row=1:rows 11 | for col=1:cols 12 | s = [s mat2string(c{row,col})]; 13 | if (col < cols) 14 | s = [s sprintf(' ...\n ')]; 15 | end 16 | end 17 | if (row < rows) 18 | s = [s sprintf(';\n ')]; 19 | end 20 | end 21 | s = [s '}']; 22 | 23 | %========================================== 24 | function s = mat2string(m) 25 | 26 | [rows,cols] = size(m); 27 | s = '['; 28 | for row=1:rows 29 | if (row ~= 1) 30 | s = [s sprintf(';\n ')]; 31 | end 32 | for col=1:cols 33 | if (col ~= 1) 34 | s = [s ' ']; 35 | end 36 | s = [s num2str(m(row,col))]; 37 | end 38 | end 39 | s = [s ']']; 40 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/private/nnmat2string.m: -------------------------------------------------------------------------------- 1 | function s = nnmat2string(m) 2 | 3 | % Copyright 1992-2002 The MathWorks, Inc. 4 | % $Revision: 1.4 $ $Date: 2002/03/25 16:55:02 $ 5 | 6 | [rows,cols] = size(m); 7 | s = '['; 8 | for row=1:rows 9 | if (row ~= 1) 10 | s = [s sprintf(';\n ')]; 11 | end 12 | for col=1:cols 13 | if (col ~= 1) 14 | s = [s ' ']; 15 | end 16 | s = [s num2str(m(row,col))]; 17 | end 18 | end 19 | s = [s ']']; 20 | -------------------------------------------------------------------------------- /ch16/matlab_code/nnet/nnutils/substring.m: -------------------------------------------------------------------------------- 1 | function str=substring(str,first,varargin) 2 | 3 | 4 | % This is a workaround for a change to the Java interface. Remove befor R12! 5 | 6 | % Copyright 1992-2002 The MathWorks, Inc. 7 | % $Revision: 1.4 $ $Date: 2002/03/25 16:55:09 $ 8 | 9 | 10 | if isempty(varargin) 11 | str=str(first+1:end); 12 | else 13 | str=str(first+1:varargin{1}+1); 14 | end 15 | -------------------------------------------------------------------------------- /ch16/matlab_code/tlm2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hhland/matlab-dadm/2353397cfe386474b747ef6aec17d5e99fe1e037/ch16/matlab_code/tlm2.m --------------------------------------------------------------------------------