Loop Question for particle
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Geoff Hayes
am 14 Mai 2020
I still don't understand how you determine "no contact" particles. Can you illustrate with an example?
Antworten (1)
Reshma Nerella
am 24 Jul. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!