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:
Plot stealing focus

Subject: Plot stealing focus

From: Sris P

Date: 19 Oct, 2010 12:52:03

Message: 1 of 3

I have a small gui matlab program that contains few textboxes and a plot. This plot is being updated every 0.1s with a loop. Something like:

while v==1
plot (x)
pause(0.1)
end

But the problem is that i want this to be running in the background. Every time a new plot is plotted, it takes the focus which means I cannot use the textboxes anymore. I want keep changing the values in the textboxes.

Any suggestions?
Regards,
Sris

Subject: Plot stealing focus

From: Steven_Lord

Date: 19 Oct, 2010 13:11:05

Message: 2 of 3



"Sris P" <nepalingraphix@yahoo.com> wrote in message
news:i9k49j$2pb$1@fred.mathworks.com...
> I have a small gui matlab program that contains few textboxes and a plot.
> This plot is being updated every 0.1s with a loop. Something like:
>
> while v==1
> plot (x)
> pause(0.1)
> end

Don't call PLOT each time; call PLOT _once_ before the loop and use SET to
update the plot with the new data.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Plot stealing focus

From: Chris

Date: 16 Jan, 2013 21:02:08

Message: 3 of 3

"Steven_Lord" <slord@mathworks.com> wrote in message <i9k5d8$jhi$1@fred.mathworks.com>...
>
>
> "Sris P" <nepalingraphix@yahoo.com> wrote in message
> news:i9k49j$2pb$1@fred.mathworks.com...
> > I have a small gui matlab program that contains few textboxes and a plot.
> > This plot is being updated every 0.1s with a loop. Something like:
> >
> > while v==1
> > plot (x)
> > pause(0.1)
> > end
>
> Don't call PLOT each time; call PLOT _once_ before the loop and use SET to
> update the plot with the new data.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


I know it's been a while since this question was asked, but there are additional options.

if you don't care to watch the plot update you can set the figure property 'Visible' to 'Off', and then turn it on at the end to view the plot. Although in this case why not simply wait to create the plot until the end?

Or, if you link the plot to data in the workspace the plot will update automatically when the variable changes.

H = plot(x);
set(H,'YDataSource','x')
linkdata on

while v==1
%do you're x updating calculations
pause(0.1)
end

Tags for 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