I wrote this code using Matlab R2014a in order to loop through a virtual grid:
clear, clcformat long gload rN_Tang.txtload aN_Tang.txtc=aN_Tang(:,:); f=rN_Tang(:,:);DepthsA=-c(:,3);LongitudeA=c(:,1);DepthsR=-f(:,3);LongitudeR=f(:,1);for I=724:747; J=2:8; k=1:length(aN_Tang); l=1:length(rN_Tang); if ((I<LongitudeA(k)<=I+1 & J<DepthsA(k)<=J+1) & ... (I<LongitudeR(l)<=I+1 & J<DepthsR(l)<=J+1)) if (isempty(DepthsA(k))==0 & isempty(DepthsR(l))==1) Zmoy(I,J)=min(DepthsA(k)); elseif (isempty(DepthsA(k))==1 & isempty(DepthsR(l))==0) Zmoy(I,J)=min(DepthsR(l)); elseif (isempty(DepthsA(k))==1 & isempty(DepthsR(l))==1) %Ne rien faire, i.e "Void"
elseif (isempty(DepthsA(k))==0 & isempty(DepthsR(l))==0) zAmin(I,J)=min(DepthsA(k)); DZ(I,J)=min(abs(zAmin(I,J)-DepthsR(l))); if zAmin(I,J)<=DepthsR(l) zRmin(I,J)=zAmin(I,J)+DZ(I,J); else zRmin(I,J)=zAmin(I,J)-DZ(I,J); end Zmoy(I,J)=(zAmin(I,J)+zRmin(I,J))/2; end end Zm=-1*mean(Zmoy(I,J))endMatlab response :"Error using < Matrix dimensions must agree.Error in plN_Tang (line 60) if ((I<LongitudeA(k)<=I+1 & J<DepthsA(k)<=J+1) & (I<LongitudeR(l)<=I+1 & J<DepthsR(l)<=J+1))"
What's wrong with the loop?
PS:I'd be so grateful if someone has an idea about this issue!
Best Answer