# Plot two functions with different pause rates at same time.

조회 수: 7(최근 30일)
Aidan McGlone 2021년 9월 14일
댓글: Aidan McGlone 2021년 9월 16일
Hello,
I'm trying to plot these two sets of data that are different lengths, but cover the same amount of ground if that makes sense. The truncatedXYZ will plot a lot faster with timesteps(pauses) of around 0.01 whereas the jittercheck will plot slower with timesteps(pauses) of around 0.1. I'm trying to get it to plot the truncatedXYZ following that pause rate and plot the jittercheck following the other pause rate at the same time and on the same graph. When I do this, it only prints the first 239 points for truncatedXYZ instead of the full 2987 because the jittercheck has already finished all of its points. I commented out the pauses because they would make it take too long to check. The final result should be the same shape in red and black. Thank you for any tips or help you can give me.
frames = 239;
trunk = 2987;
hold on
ivals = 1:trunk;
jvals = 1:frames;
for K = 1 : length(ivals)
i = ivals(K);
j = jvals(K);
plot(truncatedXYZ.rel_x(i),truncatedXYZ.rel_y(i),'or')
xlim([7.4 8.6])
ylim([2.5 5])
%pause(truncatedXYZ.timestep(i))
plot(jittercheck(j,2),jittercheck(j,3),'ok')
xlim([7.4 8.6])
ylim([2.5 5])
%pause(jittercheck(j,6))
end

댓글을 달려면 로그인하십시오.

### 채택된 답변

편집: Mohammad Sami 2021년 9월 15일
You can try something like plotting j every few steps.
frames = 239;
trunk = 2987;
hold on
lastjplotted = 0;
for i = 1:trunk
j = ceil(i*frames/trunk);
plot(truncatedXYZ.rel_x(i),truncatedXYZ.rel_y(i),'or');
xlim([7.4 8.6]);
ylim([2.5 5]);
if(j > lastjplotted)
plot(jittercheck(j,2),jittercheck(j,3),'ok');
xlim([7.4 8.6]);
ylim([2.5 5]);
lastjplotted = j;
end
pause(truncatedXYZ.timestep(i));
end
##### 댓글 수: 1표시숨기기 없음
Aidan McGlone 2021년 9월 16일
That is perfect. Thank you so much.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Line Plots 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!

Translated by