Plotting at set intervals in a for loop
Afficher commentaires plus anciens
I'm plotting partical postions in a for-loop with t as followed:
t = 0:timeStep:timeStep*nrOfTimeSteps
Now I think the bulk of my code is not required for this question. I want to plot the particle positions in a scatter plot at four set intervals namely [0, 1/4, 1/2, 3/4, 1] of the total time. Everything I've tried so far plots either 0 points, the particle positions at the end, or all the positions at each time step (hold on).
What is the way to implement this within my loop?
Thanks in advance
4 commentaires
Kirby Fears
le 30 Sep 2015
Are you trying to scatterplot Y values for X between [0,1/4] in one plot, then repeat for X between [1/4,1/2] in a second plot, etc?
NotSoWiseman
le 30 Sep 2015
Modifié(e) : NotSoWiseman
le 30 Sep 2015
Shigeo Nakajima
le 5 Jan 2017
If I was looking for what you stated (Kirby Fears), how would I do that?
Kirby Fears
le 5 Jan 2017
Modifié(e) : Kirby Fears
le 5 Jan 2017
Shigeo,
This will plot all (X,Y) position pairs for time between 0-1/4 in one plot, time between 1/4-1/2 in a second plot, etc.
T=0.1:0.1:10;
X=rand(numel(T),100);
Y=rand(numel(T),100);
stepSize=numel(T)/4;
tPoints=round(0:stepSize:numel(T));
for t = 1:(numel(tPoints) - 1),
xVals = X(tPoints(t)+1:tPoints(t+1),:);
yVals = Y(tPoints(t)+1:tPoints(t+1),:);
figure();
scatter(xVals(:),yVals(:));
end,
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!