project1.asv
上传用户:miaohui010
上传日期:2013-01-08
资源大小:2540k
文件大小:1k
开发平台:

Matlab

  1. load vehicle;
  2. load background;
  3. for j=1:10
  4. k_s=1;
  5. k_d=252;
  6. vec_tr(250,252)=0;
  7. vec_test(250,252)=0;
  8. [vec_tr,vec_test]=randQ(vehicle);
  9. randQ(background);
  10. bg_tr(250,252)=0;
  11. bg_test(250,252)=0;
  12. [bg_tr,bg_test]=randQ(background);
  13. M_vec=vec_tr(1,k_s:k_d);
  14. for i=2:250
  15. M_vec=M_vec+(vec_tr(i,k_s:k_d));
  16. end
  17. M_vec=M_vec/250;
  18. M_bg=bg_tr(1,k_s:k_d);
  19. for i=2:250
  20. M_bg=M_bg+(bg_tr(i,k_s:k_d));
  21. end
  22. M_bg=M_bg/250;
  23. d_vec=(M_vec*M_vec')/2;
  24. d_bg=(M_bg*M_bg')/2;
  25. flag_vec(250)=0;
  26. flag_bg(250)=0;
  27. dk_vec=0;
  28. dk_bg=0;
  29. for i=1:250
  30.     dk_vec=vec_test(i,k_s:k_d)*M_vec'-d_vec;
  31.     dk_bg=vec_test(i,k_s:k_d)*M_bg'-d_bg;
  32.     if(dk_vec>=dk_bg)
  33.         flag_vec(i)=1;
  34.     else flag_vec(i)=0;
  35.     end
  36. end
  37. s1_vec=sum(flag_vec);
  38. for i=1:250
  39.     dk_vec=bg_test(i,k_s:k_d)*M_vec'-d_vec;
  40.     dk_bg=bg_test(i,k_s:k_d)*M_bg'-d_bg;
  41.     if(dk_bg>=dk_vec)
  42.         flag_bg(i)=1;
  43.     else flag_bg(i)=0;
  44.     end
  45. end
  46. s1_bg=sum(flag_bg);
  47. err_vg(j)=(250-s1_vec)/500;
  48. err_gv(j)=(250-s1_bg)/500;
  49. end
  50. err_VG=0;err_GV=0;
  51. for i=1:10
  52.     err_VG=err_VG+err_vg(i);
  53.     err_GV=err_GV+err_gv(i);
  54. end
  55. err_VG=err_VG/10
  56. err_GV=err_GV/10
  57.     
  58.     
  59.