Why do I get "Array indices must be positive integers or logical values"
Afficher commentaires plus anciens
J=rand(9);
K=rand(12);
L=rand(10);
a=meshgrid(J,K,L);
sc=3;
[n,m,p0]=size(a);
SI=zeros(n,m,p0);
for ii=1:n
for jj=1:m
td(:,1)=reshape(a(ii,jj,:),p0,1);
if length(td(td>=0))/length(td)~=1
SI(ii,jj,:)=nan;
else
SI(ii,jj,1:sc-1)=nan;
A1=[];
for i=1:sc,
A1=[A1,td(i:length(td)-sc+i)];
end
Y=sum(A1,2);
nn=length(Y);
SI1=zeros(nn,1);
for k=1:12
d=Y(k:12:nn);
Xn=Y(d);
[zeroa]=find(Xn==0);
Xn_nozero=Xn;Xn_nozero(zeroa)=[];
q=length(zeroa)/length(Xn);
parm=gamfit(Xn_nozero);
Gam_xs=q+(1-q)*gamcdf(Xn,parm(1),parm(2));
Z(d)=norminv(Gam_xs);
end
SI1(:,1)=norminv(SI1(:,1));
%output
SI(ii,jj,sc:end)=SI1;
2 commentaires
Walter Roberson
le 1 Oct 2020
By the way, I suggest changing
if length(td(td>=0))/length(td)~=1
to
if nnz(td>=0) ~= numel(td)
Nurul Ain Basirah Zakaria
le 1 Oct 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!