format long;t=1:100:8460000; k=7e-6;b=13.8; F=zeros(size(t)); c=3e8; v=0.064.*c; eNi=3.9e10;eCo=6.8e9;tNi=8.8*86400;tCo=111.3*86400;M=1.9891e33; Mej=6.5*M; kr=[inf 0.014 inf 0.021 0.021 0.021 0.021 0.021]; A=4.75e13.*kr.*2.1*(0.62*3)^(-2);M_Ni=[2.0 2.0 0 0 0.1 0.2 0.5 1.0]*M; tm=sqrt((2.*k.*Mej)/(b.*v.*c));for r=1:numel(t) f=Pfunction(tm,eNi,eCo,tNi,tCo,M_Ni); F(r)=integral(f,0,t(r));endL=(2/tm).*exp((-t.^2)./tm^2).*(1-exp(-A.*t.^2)).*F;function f=Pfunction(tm,eNi,eCo,tNi,tCo,M_Ni)f=@(x)exp(x.^2./tm^2).*x./tm.*eNi.* M_Ni.*exp(-x./tNi) + eCo.* M_Ni.*( ... (exp(-x./tCo)-exp(-x./tNi))./(1-tNi/tCo));
This is what I have tried,but it showed that "The matrix dimensions must be consistent."I wanna change the parameters and then evaluate the function again,cause the parameter M_Ni is a matrix.What should I do ?
Best Answer