Loop Question for particle
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have following data I want to use first 2 columns in a for loop to detect the particles for which there is no contact. first 2 columns show 2 particles which are in contact. How can I get an output in tabular form. Basically i want to detect those particles for which there is no contact. Particles are 484 and total number of contacts is 956.
1 324 0.720141865396207E+00 0.000000000000000E+00 0 0.000000000000000E+00
1 439 0.940050831127248E+00 0.000000000000000E+00 0 0.000000000000000E+00
1 441 0.131609998985588E+01 0.000000000000000E+00 0 0.000000000000000E+00
2 25 0.363379567116406E+00 -0.000000000000000E+00 0 0.000000000000000E+00
2 89 0.753090369602638E+00 0.000000000000000E+00 0 0.000000000000000E+00
2 109 0.851303474754872E+00 0.000000000000000E+00 0 0.000000000000000E+00
2 220 0.898508917122121E+00 -0.000000000000000E+00 0 0.000000000000000E+00
3 6 0.890341369366110E+00 0.000000000000000E+00 0 0.000000000000000E+00
3 26 0.283864328102457E+00 0.000000000000000E+00 0 0.000000000000000E+00
Data = importdata('dem22.txt');
Particle1 = Data(:,1);
Particle2 = Data(:,2);
number_of_particles = 484
total_contacts = length(Particle1);
Contact = Particle1+Particle2
Table = cell(956,2);
for i = 1:1:ncont;
j = 1:npa;
Contact(ncont,1) = i;
i = i+1;
Contact(ncont,2) = j;
j=j+1;
Table(i,:) = {i j};
fprintf('%d %d\n', Table{i,:});
end
T = table(Contact,npa);
4 comentarios
Geoff Hayes
el 14 de Mayo de 2020
I still don't understand how you determine "no contact" particles. Can you illustrate with an example?
Respuestas (1)
Reshma Nerella
el 24 de Jul. de 2020
Hi,
Total_Particles - all particles
Particle1 - particles in column 1
Particle2 - particles in column 2
Contacted_Particles=union(Particle1, Particle2 ) - all particles that are in contact
setdiff(Total_Particles,Contacted_Particles) - gives particles that are not in contact.
Total_Particles, Particle1, Particle2 are all arrays with particle numbers
0 comentarios
Ver también
Categorías
Más información sobre Data Type Identification en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!