how to add array after the iteration
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!