saving data that calculates in the loop

2 visualizaciones (últimos 30 días)
Laura
Laura el 6 de Jun. de 2016
Editada: Laura el 6 de Jun. de 2016
Hi everyone
I want to save the value 'ang' in my code as shown below. I want to look for particles that in the distance from 'rmin' to 'rmin+dr' and calculate the angle for it. I dont want to calculate the angle for the same particles such as when j=1,k=1, j=2,k=2, and so on. First problem, the way that I set up in my code ang(j,k), the data(ang) will give 0 degree for j=1,k=1, and so on. Second problem, when the particle distance is not in the range of rmin to rmin+dr, the code also fills with 0 degree. I do not want both problems to be happened.
I was thinking to delete zero components but it would not be right because if the particles align on horizontal (has the same value of y), then angle will be zero and this is ok.
Please helps. Thanks
clear all
close all
% Minimum value of r is one particle diameter
rmin=[0.0944069743882630];
% Define the shell thickness (dr).
dr=rmin/2;
XTtrue=[-.35 -.25 -.38 -.42 -.3];
YTtrue=[ -.28 -.22 -.18 -.35 -.37];
% Loop all number of the particles.
for j=1:5
for k=1:5
Count=0;
if j~=k
% distance between x position
sepx=(XTtrue(1,k)-XTtrue(1,j));
% distance between y position
sepy=(YTtrue(1,k)-YTtrue(1,j));
% Separation between the center to-center of any particles.
dist= sqrt(sepx^2 +sepy^2);
% angle between particle-particle respects to flow x-direction
% atan2d is invert tangent and use to find angle in degree
% unit. Because atan2d returns angle between -180 to 180
% degree. Mod(atan2d,360) to account angle between 0-360.
% Count the number of particles inside the distance r and r +dr
if (dist>= rmin && dist<=(rmin+dr) )
ang(j,k)=mod(atan2d(sepy,sepx),360);
end
end
end
end

Respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by