Plotting at set intervals in a for loop
古いコメントを表示
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 件のコメント
Kirby Fears
2015 年 9 月 30 日
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
2015 年 9 月 30 日
編集済み: NotSoWiseman
2015 年 9 月 30 日
Shigeo Nakajima
2017 年 1 月 5 日
If I was looking for what you stated (Kirby Fears), how would I do that?
Kirby Fears
2017 年 1 月 5 日
編集済み: Kirby Fears
2017 年 1 月 5 日
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,
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Solver Outputs and Iterative Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!