project1.asv
资源名称:matlab作业.rar [点击查看]
上传用户:miaohui010
上传日期:2013-01-08
资源大小:2540k
文件大小:1k
源码类别:
人工智能/神经网络
开发平台:
Matlab
- load vehicle;
- load background;
- for j=1:10
- k_s=1;
- k_d=252;
- vec_tr(250,252)=0;
- vec_test(250,252)=0;
- [vec_tr,vec_test]=randQ(vehicle);
- randQ(background);
- bg_tr(250,252)=0;
- bg_test(250,252)=0;
- [bg_tr,bg_test]=randQ(background);
- M_vec=vec_tr(1,k_s:k_d);
- for i=2:250
- M_vec=M_vec+(vec_tr(i,k_s:k_d));
- end
- M_vec=M_vec/250;
- M_bg=bg_tr(1,k_s:k_d);
- for i=2:250
- M_bg=M_bg+(bg_tr(i,k_s:k_d));
- end
- M_bg=M_bg/250;
- d_vec=(M_vec*M_vec')/2;
- d_bg=(M_bg*M_bg')/2;
- flag_vec(250)=0;
- flag_bg(250)=0;
- dk_vec=0;
- dk_bg=0;
- for i=1:250
- dk_vec=vec_test(i,k_s:k_d)*M_vec'-d_vec;
- dk_bg=vec_test(i,k_s:k_d)*M_bg'-d_bg;
- if(dk_vec>=dk_bg)
- flag_vec(i)=1;
- else flag_vec(i)=0;
- end
- end
- s1_vec=sum(flag_vec);
- for i=1:250
- dk_vec=bg_test(i,k_s:k_d)*M_vec'-d_vec;
- dk_bg=bg_test(i,k_s:k_d)*M_bg'-d_bg;
- if(dk_bg>=dk_vec)
- flag_bg(i)=1;
- else flag_bg(i)=0;
- end
- end
- s1_bg=sum(flag_bg);
- err_vg(j)=(250-s1_vec)/500;
- err_gv(j)=(250-s1_bg)/500;
- end
- err_VG=0;err_GV=0;
- for i=1:10
- err_VG=err_VG+err_vg(i);
- err_GV=err_GV+err_gv(i);
- end
- err_VG=err_VG/10
- err_GV=err_GV/10