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:
Moving line on plot (animation)

Subject: Moving line on plot (animation)

From: Corey Scheip

Date: 20 May, 2011 17:20:20

Message: 1 of 4

I have some sound data I am playing via

>> sound(y, fs)

The same function creates a 2x1 subplot where the top subplot is the pressure vs. time waveform and the bottom subplot is the spectrogram of the same data.

When I run the function, I want a vertical white line to start on both subplots from 0 and follow the audio till the end (30 seconds).

Any pointers? Thanks!

Subject: Moving line on plot (animation)

From: Florin Neacsu

Date: 20 May, 2011 17:33:05

Message: 2 of 4

"Corey Scheip" wrote in message <ir67sk$hrh$1@newscl01ah.mathworks.com>...
> I have some sound data I am playing via
>
> >> sound(y, fs)
>
> The same function creates a 2x1 subplot where the top subplot is the pressure vs. time waveform and the bottom subplot is the spectrogram of the same data.
>
> When I run the function, I want a vertical white line to start on both subplots from 0 and follow the audio till the end (30 seconds).
>
> Any pointers? Thanks!

Hi,

I think you can do it with

>hold on
and
>pause

(maybe you will need drawnow too, but not sure about that)

Regards,
Florin

Subject: Moving line on plot (animation)

From: Corey Scheip

Date: 23 May, 2011 13:25:04

Message: 3 of 4

Thanks for the reply Florin, but I still haven't gotten it to work without redrawing the entire plot after each iteration of drawing a white vertical line. i.e.:

>> subplot(2,1,1); plot(x,y); hold on; line([x1 x2], [y1 y2]);
>> subplot(2,1,1); plot(x,y); hold on; line([x3 x4], [y3 y4]);

Once you draw a line using the 'line' command, is there a way to clear that line off of the plot?

Thanks.

Subject: Moving line on plot (animation)

From: Steven_Lord

Date: 23 May, 2011 13:49:28

Message: 4 of 4



"Corey Scheip" <cmscheip@ncsu.edu> wrote in message
news:irdn7g$29v$1@newscl01ah.mathworks.com...
> Thanks for the reply Florin, but I still haven't gotten it to work without
> redrawing the entire plot after each iteration of drawing a white vertical
> line. i.e.:
>
>>> subplot(2,1,1); plot(x,y); hold on; line([x1 x2], [y1 y2]);
>>> subplot(2,1,1); plot(x,y); hold on; line([x3 x4], [y3 y4]);
>
> Once you draw a line using the 'line' command, is there a way to clear
> that line off of the plot?

DELETE it using its handle, which you can obtain by calling LINE with an
output argument or using FINDOBJ or FINDALL.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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