Azzera filtri
Azzera filtri

Loop Question for particle

1 visualizzazione (ultimi 30 giorni)
shah nawaz
shah nawaz il 13 Mag 2020
Risposto: Reshma Nerella il 24 Lug 2020
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 Commenti
Geoff Hayes
Geoff Hayes il 14 Mag 2020
I still don't understand how you determine "no contact" particles. Can you illustrate with an example?
shah nawaz
shah nawaz il 14 Mag 2020
I want to determine those particles which are not in column1 and columns2 and count them. total particles 484

Accedi per commentare.

Risposte (1)

Reshma Nerella
Reshma Nerella il 24 Lug 2020
Hi,
You can use union and setdiff functions to find out the particles that are not in contact.
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

Categorie

Scopri di più su Data Type Identification in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by