フィルターのクリア

Loop Question for particle

1 回表示 (過去 30 日間)
shah nawaz
shah nawaz 2020 年 5 月 13 日
回答済み: Reshma Nerella 2020 年 7 月 24 日
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 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 5 月 14 日
I still don't understand how you determine "no contact" particles. Can you illustrate with an example?
shah nawaz
shah nawaz 2020 年 5 月 14 日
I want to determine those particles which are not in column1 and columns2 and count them. total particles 484

サインインしてコメントする。

回答 (1 件)

Reshma Nerella
Reshma Nerella 2020 年 7 月 24 日
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

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by