Borrar filtros
Borrar filtros

changing values of an edit box on gui while timer is printing on a figure

1 visualización (últimos 30 días)
Hello,
I am running a timer, where it takes real data and plots them every 0.1 seconds. I am plotting the data on a normal figure(not embedded in gui). I also created a gui so that i can change some values in real time. However, whenever I click on edit box to change some values, I have only 0.1 sec to write something in the edit box (which is not enough...) before the plot callback command runs. Once the plot callback commands starts I have to click with my mouse again in the edit box to be able to write in it..
Is there a way, to make the gui the main window so that i can write in edit boxes while updating the figure in real time?
Thanks.. M

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 6 de Nov. de 2012
Editada: Sean de Wolski el 6 de Nov. de 2012
How are you plotting it? If you update the Data of an existing HG object, focus will not be requested. Consider this example:
figure;axes;
hPlot = plot(1:10);
T = timer('Period',0.25,'TimerFcn',@(~,~)set(hPlot,'YData',rand(1,10)),...
'TasksToExecute',200,'ExecutionMode','FixedRate'); %Note updatign existing line!
start(T);
figure;
uicontrol('style','edit','String','Type in me!');

Más respuestas (2)

N/A
N/A el 6 de Nov. de 2012
hey Sean, Thanks, I was calling in my callback
1- hplot = figure(1);
2- axes;
3- set(hPlot,'YData',rand(1,10))
i removed line 1 and 2
and added
refreshdata
as well in the end, and all works fine!!! thanks!

N/A
N/A el 7 de Nov. de 2012
Editada: N/A el 7 de Nov. de 2012
Hi, I stuck on a similar issue, and I am trying below to be descriptive and I would really appreciate your help..
Problem description : If I have a function plothings() within my callback function, which runs every 10 iterations (for example)
%
% this is in callback function
...
time =time+1
if mod(time,10)==0
plotthings()
end
...
%
then the function plots the figure every time it enters the if loop as expected. Now if I also want to plot things (using plotOtherthings() ), but this time whenever I click a button at a gui, then I am not able to make the figure show as soon as I press the button, but it updates only when the plotthings() in callback is excecuted. The only way i manage to sort this out.. is to do the following
% this is a callback function in Mygui.m where the gui keeps its functions
function plotOtherthings_Callback(hObject, eventdata, handles)
updateMonitors();
refreshdata
where
% helper function for updating monitors
function updateMonitors()
global monitors
1)%h = figure(monitors.h); % I generated and saved this as monitors.h = figure(1)
2)% OR axes(monitors.ax); works as well
p1 = monitors.p1; % I generated and saved this as monitors.p1 = plot(...)
set(p1,'XDataSource','x1'); % x1 is a variable in workspace
refreshdata
My issue is that to make it appear whenever I click the button i have to use line 1) or 2) to make figure as my current figure...which I do not want to do as I need the main window to be the gui..(as that was my initial issue in original post..)
  1 comentario
N/A
N/A el 7 de Nov. de 2012
Ok,.. for some reason , 'XDatasource' should be replaced with 'XData'. Even though I would have liked to understand the difference...

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by