Plotting at set intervals in a for loop
Mostrar comentarios más antiguos
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 comentarios
Kirby Fears
el 30 de Sept. de 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
el 30 de Sept. de 2015
Editada: NotSoWiseman
el 30 de Sept. de 2015
Shigeo Nakajima
el 5 de En. de 2017
If I was looking for what you stated (Kirby Fears), how would I do that?
Kirby Fears
el 5 de En. de 2017
Editada: Kirby Fears
el 5 de En. de 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,
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!