Error Message: Subscript indices must either be real positive integers or logicals. This occurs when running the for loop for the very last value of a. Perhaps someone may be able to assist me.

sigma_lam=.7; sigma_m=.3; sigma_k=1-sigma_m; intgr=ones(1,1101); z=0:1100; zint=(z+1).^(-1); D_1=((sigma_lam*((z+1).^(-3))+sigma_k*((z+1).^(-1))+sigma_m).^(.5))./(z+1).^(-1.5); a=linspace(1/1101,1,1101); aa=num2cell(a); zplusone=0:1100; zplusone=fliplr(zplusone); zplusonea=num2cell(zplusone); scalefactor_z= containers.Map(aa,zplusonea);
for a=linspace(1/1101,1,1101); x=0:.0001:a; y=x.^(1.5)./((sigma_lam*x.^3+sigma_k*x+sigma_m).^(1.5)); intgr(1,scalefactor_z(a))=trapz(x,y); end
intgr=fliplr(intgr);
global D_fin
D_fin=intgr.*D_1;
for i=1:1101 f_col(1,i)=erfc(1.69/(sqrt(2)*D_fin(i)*7)); end
plot(z,f_col)
%sigma(M,z)=(D(z)/D(0))*sigma(M,0); %put in D(z)
%then plot f_col

回答(1 个)

The error occurs for the line
intgr(1,scalefactor_z(a)) = trapz(x,y);
because with a equal to 1
K>> scalefactor_z(a)
ans =
0
which is not a positive integer

此问题已关闭。

提问:

2013-12-6

关闭:

2021-8-20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by