필터 지우기
필터 지우기

how to add array after the iteration

조회 수: 1 (최근 30일)
singh
singh 2015년 5월 3일
i have two array which are used in the for loop and after iteration of for loop one array will be empty and another array have some values.after second iteration first array have some value and another array will be empty.empty array have not a length but valued array always contain same length. now i wish to add both array if it have value until iteration will be over.after all iteration over then i get total of these array which contain values.
for i=1:4
dist1=[];
dist2=[];
if i>=2 &&i<=4
for i3=1:length(XY)
X12=horzcat([XY12{i-1}]);
Y12=horzcat([XY12{i}]);
X1=X12(i,1);
Y1=X12(i,2);
X2=Y12(i,1);
Y2=Y12(i,2);
E_coord=[X1,Y1;X2,Y2];
Dcoord=pdist(E_coord,'euclidean');
dist1(i)=Dcoord;
end
else
for i=1:length(XY)
X10=XY(i,3);
Y10=XY(i,4);
X11=Xx(i);
Y11=Yy(i);
ECOORD=[X10,Y10;X11,Y11];
DCOORD=pdist(ECOORD,'euclidean');
dist2(i)=DCOORD;
end
end
d=[dist2]'
d=[dist1]'
now i wish to add the dist1 and dist2 if it contain values otherwise if it has not values then doesn't add these array. and plz give me short solution
thanks in advance

답변 (0개)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by