Info

This question is closed. Reopen it to edit or answer.

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.

1 view (last 30 days)
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

Answers (1)

per isakson
per isakson on 6 Dec 2013
Edited: per isakson on 6 Dec 2013
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

Community Treasure Hunt

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

Start Hunting!