plotting the trajectories of three particles in same graph

I have three particles with x and y values of each particle, I neet to plot all three trajectories in same graph. How can I do it?

 Accepted Answer

Try this:
plot(x1, y1, 'r-', 'LineWidth', 3);
hold on;
plot(x2, y2, 'g-', 'LineWidth', 3);
plot(x3, y3, 'b-', 'LineWidth', 3);
grid on;
xlabel('x', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
title('Demo by Image Analyst', 'FontSize', fontSize);
legend('y1', 'y2', 'y3');

4 Comments

I have time column as well but if it says to plot the trajectories of these particles. so do I have to include time as well.
If all the x are the same time variable t, you can simply do
plot(t, y1, 'r-', 'LineWidth', 3);
hold on;
plot(t, y2, 'g-', 'LineWidth', 3);
plot(t, y3, 'b-', 'LineWidth', 3);
grid on;
xlabel('Time', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
title('Demo by Image Analyst', 'FontSize', fontSize);
legend('y1', 'y2', 'y3');
Its variable t and with respect to t there is variable x and y for each three particle.
If x and y are parameterized variables depending on t, then the first code snippet I sent you will work.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Asked:

Ls
on 10 Aug 2021

Commented:

on 10 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!