Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simple anmation: connect points with the line segment

Subject: Simple anmation: connect points with the line segment

From: Liana

Date: 13 May, 2011 18:22:04

Message: 1 of 4

Hi!

I'd like to make a simple animation. At each ith step I need to plot a new point that is connected to a previous point with the line segment. As a result a curved line should be plotted. Although I'm using '--ro', the points are not connected with the line segment. Any suggestions? Thanks.

figure(1)
set(gcf,'Color','w');
hold off
xlabel('Iteration');
ylabel('Parameter1');

for i = 1 : N
        plot(i,val(1,i),'--ro','LineWidth',2);
        hold on
        plot(i,val(2,i),'--b*','LineWidth',2);
        title(['Iteration = ' num2str(i) ']);
        drawnow;
end

Subject: Simple anmation: connect points with the line segment

From: ImageAnalyst

Date: 13 May, 2011 18:27:10

Message: 2 of 4

You're only giving plot one coordinate to plot. You didn't give us
val to try your code with. So without that, I'd recommend using
line() to draw the lines in between the two endpoints. Only use
plot() to draw markers (e.g. circles, squares, etc.), in the event you
want those. You can do it with plot also but you'll need to construct
an array of both endpoints and plot that, instead of just one endpoint
like you're doing now.

Either way....

Subject: Simple anmation: connect points with the line segment

From: Liana

Date: 13 May, 2011 18:43:04

Message: 3 of 4

Thank you. Now I see the problem. Let me concertize my question. I need just to plot a "tail", and each new point should add a new line segment to that tail. I cannot predefine x and y arrays, because they are calculated dynamically and I need to plot the dynamic changes of 2D curve.

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <724d8f67-e3c8-4324-b848-0d3749215f37@s9g2000yqm.googlegroups.com>...
> You're only giving plot one coordinate to plot. You didn't give us
> val to try your code with. So without that, I'd recommend using
> line() to draw the lines in between the two endpoints. Only use
> plot() to draw markers (e.g. circles, squares, etc.), in the event you
> want those. You can do it with plot also but you'll need to construct
> an array of both endpoints and plot that, instead of just one endpoint
> like you're doing now.
>
> Either way....

Subject: Simple anmation: connect points with the line segment

From: ImageAnalyst

Date: 13 May, 2011 19:51:38

Message: 4 of 4

On May 13, 2:43 pm, "Liana " <liananapalk...@email.arizona.edu> wrote:
> Thank you. Now I see the problem. Let me concertize my question.
----------------------------------------------------
But with your added "concertizement" I still don't think that would
change my answer, which is to plot a 2-point array or use the line()
function. Perhaps you can ask a more targeted question.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us