You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

#### 442 lines 15 KiB Matlab Raw Permalink Blame History

 ```function collision_physics ``` ```%calculate which mass is heaviest from observations of initial velocities and velocities after collision. Velocities match those used in corresponding psychophysics experiments (in cm/s). Mass ratios also match those used in corresponding psychophysics experiments. ``` ```figoff=20; ``` ```Vinp=[-12:1:12]; ``` ```Vcen=[-6:2:6]; ``` ```Einp=[-0.4:0.2:1.4]; ``` ```Ecen=[0:0.25:1]; ``` ```Rinp=[1:-1:-1]; ``` ```Rcen=[1/3,1/2,1,2,3]; ``` ```expon=2; ``` ```precV=0.03; %precision to encode velocities ``` ``` ``` ```%define weights of prediction neurons representing a range of perfectly elastic collisions ``` ```W=[]; ``` ```for ua=Vcen ``` ``` for ub=Vcen ``` ``` for e=Ecen ``` ``` for r=Rcen ``` ``` [va,vb]=post_collision_velocities(r,1,ua,ub,e); ``` ``` if ua>ub && va<=ua && vb>=ub %necessary for there to be a collision ``` ``` if (vb-ub)>(ua-va), rr=1; %Ma larger ``` ``` elseif (vb-ub)<(ua-va), rr=-1; %Mb larger ``` ``` else rr=0; %Ma=Mb ``` ``` end ``` ``` W=[W;code(ua,Vinp,0.5),code(ub,Vinp,0.5),code(va,Vinp,0.5),code(vb,Vinp,0.5),code(e,Einp,10),code(rr,Rinp,10)];%code(log(r),Rinp,10)]; ``` ``` end ``` ``` end ``` ``` end ``` ``` end ``` ```end ``` ```[n,m]=size(W) ``` ```nullE=zeros(1,length(Einp)); ``` ```nullR=zeros(1,length(Rinp)); ``` ``` ``` ``` ``` ```%simulate Expt 1 of Todd & Warren ``` ```Ua=[1.19:0.13:4.45]; ``` ```mb=1; ``` ```Ma=[1.25,1.5,2,3]; ``` ```E=[0.9,0.5,0.1]; ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` for ua=Ua ``` ``` ub=ua-6.35; ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),code(va,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(k,j)=est(k,j)+chooseA; ``` ``` num(k,j)=num(k,j)+1; ``` ``` end ``` ``` end ``` ```end ``` ```est=est./num; ``` ```figure(figoff+1),clf ``` ```semilogx(Ma,est(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,est(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9) ``` ```semilogx(Ma,est(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9) ``` ```semilogx([1,3],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1,1.5,3],'XTickLabel',['1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics1.pdf'); ``` ``` ``` ``` ``` ``` ``` ```%simulate Expt 2 of Todd & Warren - moving condition ``` ```ua=3.18; ``` ```ub=-3.18; ``` ```mb=1; ``` ```Ma=[1/3,0.5,2/3,1/1.25,1.25,1.5,2,3]; ``` ```E=[0.9,0.5,0.1]; ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),code(va,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(k,j)=est(k,j)+chooseA; ``` ``` num(k,j)=num(k,j)+1; ``` ``` end ``` ```end ``` ```est=est./num; ``` ```figure(figoff+2),clf ``` ```semilogx(Ma,est(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,est(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9) ``` ```semilogx(Ma,est(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9) ``` ```semilogx([1,1],[0,1],'k--') ``` ```semilogx([1/3,3],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics2.pdf'); ``` ``` ``` ``` ``` ``` ``` ```%simulate Expt 2 of Todd & Warren - stationary condition (reproduced in Fig.5 of Sanborn, Mansinghka, and Griffiths) ``` ```ua=3.18; ``` ```ub=0; ``` ```mb=1; ``` ```Ma=[1/3,0.5,2/3,1/1.25,1.25,1.5,2,3]; ``` ```E=[0.9,0.5,0.1]; ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),code(va,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(k,j)=est(k,j)+chooseA; ``` ``` num(k,j)=num(k,j)+1; ``` ``` end ``` ```end ``` ```est=est./num; ``` ```figure(figoff+3),clf ``` ```semilogx(Ma,est(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,est(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9) ``` ```semilogx(Ma,est(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9) ``` ```semilogx([1,1],[0,1],'k--') ``` ```semilogx([1/3,3],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics3.pdf'); ``` ``` ``` ``` ``` ``` ``` ``` ``` ```%simulate experiment shown in Fig.4 of Runesun and Vedeler ``` ```Mb=[0.25,0.37,0.55,0.82,1.22,1.81,2.69,4]; ``` ```ma=1; ``` ```e=0.9; ``` ```num=zeros(4,length(Mb)); ``` ```est=zeros(4,length(Mb)); ``` ```for condition=1:4 ``` ``` if isodd(condition) ``` ``` ua=3; ub=-1; ``` ``` else ``` ``` ua=5; ub=1; ``` ``` end ``` ``` ua=ua*5.1/4; ``` ``` ub=ub*5.1/4; ``` ``` j=0; ``` ``` for mb=Mb ``` ``` j=j+1; ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` if condition<2.5 ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),code(va,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` else ``` ``` x=[0.*code(ua,Vinp,precV),0.*code(ub,Vinp,precV),code(va,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` end ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(condition,j)=chooseA; ``` ``` end ``` ```end ``` ```figure(figoff+4),clf ``` ```%semilogx(Mb,est(1,:),'y-o','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9),hold on ``` ```%semilogx(Mb,est(2,:),'y-s','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9) ``` ```%semilogx(Mb,est(3,:),'y-o','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9) ``` ```%semilogx(Mb,est(4,:),'y-s','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9) ``` ```semilogx(1./Mb,mean(est(1:2,:)),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(1./Mb,mean(est(3:4,:)),'m--d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9) ``` ```semilogx([1,1],[0,1],'k--') ``` ```semilogx([1/4,4],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1/4,1/2,1,2,4],'XTickLabel',['1/4';'1/2';'1/1';'2/1';'4/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics4.pdf'); ``` ``` ``` ``` ``` ``` ``` ```%simulate experiment shown in Fig.3a of Sanborn ``` ```Ua=[1.19:0.13:4.45]; ``` ```ub=0; ``` ```mb=1; ``` ```Ma=[1/3,1/1.25,1.25,3]; ``` ```E=[1,0.1]; ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` for ua=Ua ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),code(va,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(k,j)=est(k,j)+chooseA; ``` ``` num(k,j)=num(k,j)+1; ``` ``` end ``` ``` end ``` ```end ``` ```est=est./num; ``` ```figure(figoff+5),clf ``` ```semilogx(Ma,est(1,:),'r-+','LineWidth',2,'MarkerFaceColor','r','MarkerSize',9),hold on ``` ```semilogx(Ma,est(2,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9) ``` ```semilogx([1,1],[0,1],'k--') ``` ```semilogx([1/3,3],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics5.pdf'); ``` ``` ``` ``` ``` ```scale=0.2; ``` ```%simulate experiment shown in Fig.3b of Sanborn (as above but with object B occluded after collision) ``` ```Ua=[1.19:0.13:4.45]; ``` ```ub=0; ``` ```mb=1; ``` ```Ma=[1/3,1/1.25,1.25,3]; ``` ```E=[1,0.1]; ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` for ua=Ua ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),code(va,Vinp,precV),scale*code(ub,Vinp,precV),nullE,nullR]'; ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(k,j)=est(k,j)+chooseA; ``` ``` num(k,j)=num(k,j)+1; ``` ``` end ``` ``` end ``` ```end ``` ```est=est./num; ``` ```figure(figoff+6),clf ``` ```semilogx(Ma,est(1,:),'r-+','LineWidth',2,'MarkerFaceColor','r','MarkerSize',9),hold on ``` ```semilogx(Ma,est(2,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9) ``` ```semilogx([1,1],[0,1],'k--') ``` ```semilogx([1/3,3],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics6.pdf'); ``` ``` ``` ``` ``` ```%simulate experiment shown in Fig.3c of Sanborn (as above but with object A occluded after collision) ``` ```Ua=[1.19:0.13:4.45]; ``` ```ub=0; ``` ```mb=1; ``` ```Ma=[1/3,1/1.25,1.25,3]; ``` ```E=[1,0.1]; ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` for ua=Ua ``` ``` [va,vb]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),scale*code(ua,Vinp,precV),code(vb,Vinp,precV),nullE,nullR]'; ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` predict=r(m-length(Rinp)+1:m)'.^expon; ``` ``` chooseA=0.5+0.5.*sum(Rinp.*predict)./sum(predict); ``` ``` est(k,j)=est(k,j)+chooseA; ``` ``` num(k,j)=num(k,j)+1; ``` ``` end ``` ``` end ``` ```end ``` ```est=est./num; ``` ```figure(figoff+7),clf ``` ```semilogx(Ma,est(1,:),'r-+','LineWidth',2,'MarkerFaceColor','r','MarkerSize',9),hold on ``` ```semilogx(Ma,est(2,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9) ``` ```semilogx([1,1],[0,1],'k--') ``` ```semilogx([1/3,3],[0.5,0.5],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('proportion choosing object A') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics7.pdf'); ``` ``` ``` ``` ``` ```corKnown=1 ``` ```%simulate predictions of post-collision velocities ``` ```ua=3.18; ``` ```ub=-3.18; ``` ```mb=1; ``` ``` ``` ```Ma=[1/3,0.5,2/3,1/1.25,1.25,1.5,2,3]; ``` ```E=[0.9,0.5,0.1]; ``` ```partitionVa=2*length(Vinp)+[1:length(Vinp)]; ``` ```partitionVb=3*length(Vinp)+[1:length(Vinp)]; ``` ```nullV=zeros(1,length(Vinp)); ``` ``` ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` if corKnown ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),nullV,nullV,code(e,Einp,10),code(log(ma),Rinp,1)]'; ``` ``` else ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),nullV,nullV,nullE,code(log(ma),Rinp,1)]'; ``` ``` end ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` rVa=r(partitionVa)'.^expon; ``` ``` rVb=r(partitionVb)'.^expon; ``` ``` predictVa(k,j)=sum(rVa.*Vinp)./sum(rVa); ``` ``` predictVb(k,j)=sum(rVb.*Vinp)./sum(rVb); ``` ``` [trueVa(k,j),trueVb(k,j)]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` end ``` ```end ``` ``` ``` ```figure(figoff+8),clf ``` ```semilogx(Ma,trueVa(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,trueVb(1,:),'m-d','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,trueVa(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9), ``` ```semilogx(Ma,trueVb(2,:),'b-s','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,trueVa(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9), ``` ```semilogx(Ma,trueVb(3,:),'g-o','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx([1,1],[-8,8],'k--') ``` ```semilogx([1/3,3],[ub,ub],'k--') ``` ```semilogx([1/3,3],[ua,ua],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('actual post-collision velocities') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics8.pdf'); ``` ``` ``` ```figure(figoff+9),clf ``` ```semilogx(Ma,predictVa(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,predictVb(1,:),'m-d','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,predictVa(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9), ``` ```semilogx(Ma,predictVb(2,:),'b-s','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,predictVa(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9), ``` ```semilogx(Ma,predictVb(3,:),'g-o','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx([1,1],[-8,8],'k--') ``` ```semilogx([1/3,3],[ub,ub],'k--') ``` ```semilogx([1/3,3],[ua,ua],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('estimated post-collision velocities') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics9.pdf'); ``` ``` ``` ``` ``` ```ua=3.18; ``` ```ub=0; ``` ```mb=1; ``` ``` ``` ```num=zeros(length(E),length(Ma)); ``` ```est=zeros(length(E),length(Ma)); ``` ```k=0; ``` ```for e=E ``` ``` k=k+1; ``` ``` j=0; ``` ``` for ma=Ma ``` ``` j=j+1; ``` ``` if corKnown ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),nullV,nullV,code(e,Einp,10),code(log(ma),Rinp,1)]'; ``` ``` else ``` ``` x=[code(ua,Vinp,precV),code(ub,Vinp,precV),nullV,nullV,nullE,code(log(ma),Rinp,1)]'; ``` ``` end ``` ``` [y,~,r]=dim_activation(W,x); ``` ``` rVa=r(partitionVa)'.^expon; ``` ``` rVb=r(partitionVb)'.^expon; ``` ``` predictVa(k,j)=sum(rVa.*Vinp)./sum(rVa); ``` ``` predictVb(k,j)=sum(rVb.*Vinp)./sum(rVb); ``` ``` [trueVa(k,j),trueVb(k,j)]=post_collision_velocities(ma,mb,ua,ub,e); ``` ``` end ``` ```end ``` ``` ``` ```figure(figoff+10),clf ``` ```semilogx(Ma,trueVa(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,trueVb(1,:),'m-d','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,trueVa(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9), ``` ```semilogx(Ma,trueVb(2,:),'b-s','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,trueVa(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9), ``` ```semilogx(Ma,trueVb(3,:),'g-o','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx([1,1],[-2,5],'k--') ``` ```semilogx([1/3,3],[ub,ub],'k--') ``` ```semilogx([1/3,3],[ua,ua],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('actual post-collision velocities') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics10.pdf'); ``` ``` ``` ```figure(figoff+11),clf ``` ```semilogx(Ma,predictVa(1,:),'m-d','LineWidth',2,'MarkerFaceColor','m','MarkerSize',9),hold on ``` ```semilogx(Ma,predictVb(1,:),'m-d','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,predictVa(2,:),'b-s','LineWidth',2,'MarkerFaceColor','b','MarkerSize',9), ``` ```semilogx(Ma,predictVb(2,:),'b-s','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx(Ma,predictVa(3,:),'g-o','LineWidth',2,'MarkerFaceColor','g','MarkerSize',9), ``` ```semilogx(Ma,predictVb(3,:),'g-o','LineWidth',2,'MarkerFaceColor','w','MarkerSize',9), ``` ```semilogx([1,1],[-2,5],'k--') ``` ```semilogx([1/3,3],[ub,ub],'k--') ``` ```semilogx([1/3,3],[ua,ua],'k--') ``` ```set(gca,'XTick',[1/3,2/3,1,1.5,3],'XTickLabel',['1/3';'2/3';'1/1';'3/2';'3/1'],'FontSize',12) ``` ```xlabel('m_A/m_B');ylabel('estimated post-collision velocities') ``` ```set(gcf,'PaperSize',[6 9],'PaperPosition',[0 0.25 6 9],'PaperOrientation','Portrait'); ``` ```print(gcf, '-dpdf','collision_physics11.pdf'); ``` ``` ``` ``` ``` ``` ``` ``` ``` ```function c=code(x,X,precision) ``` ```if nargin<3 || isempty(precision), precision=0.5; end ``` ```c=exp(-precision.*(x-X).^2);%.*sqrt(precision); ``` ``` %c=c./sum(c); ``` ``` ``` ``` ``` ``` ``` ``` ``` ```function [va,vb]=post_collision_velocities(ma,mb,ua,ub,e) ``` ```va=((ma*ua)+mb*(ub+e*(ub-ua)))/(ma+mb); ``` ```vb=((mb*ub)+ma*(ua+e*(ua-ub)))/(ma+mb); ``` ``` ```