How to create periodic boundary conditions while plotting?
Show older comments
I want to plot 3D until the z value reaches a certain value (18 in this case), then it should start from z = 0 again. I cut down the intervals in the text file so that when it reaches 18.0 it will go to 0.0, but because I am drawing continuously, there is a line perpendicular to the x-y plane. How can I stop that from happening? I am also attaching the data. Thank you in advance!
contents = fileread('results.txt'); %read whole file at once
contents = strsplit(contents, 'Particle'); %split into cell array at particle
particles = cellfun(@(c) sscanf(c, '%f', [3 Inf])', contents(2:end), 'UniformOutput', false); %scan each section into a 3xN matrix
for i=1:length(particles)
curve=animatedline('linewidth',2,'color',rand(1,3))
for j=1:length(particles{1,i})
x = particles{1,i}(j,1);
y = particles{1,i}(j,2);
z = particles{1,i}(j,3);
figure(1)
addpoints(curve,x,y,z);
drawnow
pause(0.2);
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
