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:
MATLAB gui plot text handling depending on check box

Subject: MATLAB gui plot text handling depending on check box

From: Rouzbeh

Date: 15 Mar, 2013 12:35:07

Message: 1 of 2

hello,

I am designing a gui (my first one) with guide and I'm having some problems with certain plotting (text) options. I have two sets of axes objects in my gui which are used for graphing purposes. I also have a set of check boxes corresponding to each set of axes that do simple analysis (min, max, average). when each check box is toggled on, say for the "min" of "plot1" axes, a text box gets populated by a number corresponding to the minimum value of the data and a text object printed on the graph pointing to the corresponding value on the graph.

here's the code segment:

In my check box callback function :
axes(handles.Plot1);

if (get(handles.Panel1Min, 'Value') == get(handles.Panel1Min,'Max')) %check toggle on
    if data1MinInd>floor((length(P1t)/2)-1)
        handles.text = text(t(data1MinInd),data1Min,['some text']);
elseif data1MinInd<=floor((length(P1t)/2)-1)
       handles.text = text(t(data1MinInd),data1Min,['some other text']);
    end
else
    set(handles.P1MinText,'String',''); % if toggled off, text box is cleared
end

what I'm struggling is clearing the text from the plot when the check box is toggled off.

Things I have tried:

1) saving the "text" handle object everytime the toggle is on (because when it's off the handle doesn't exist), and check it agains the toggle before the conditional statements above in the check box callback function.

2) using the delete command and passing the "text" handle object as an input argument.

Does the line "axes(handles.Plot1)" in anyway interfere with "text" handle assignment by making it a child?

I would appreciate any help or hints that would set me on the right path to solving the problem.

Thank you,

Rouzbeh

Subject: MATLAB gui plot text handling depending on check box

From: Kristin

Date: 19 Mar, 2013 23:03:13

Message: 2 of 2

"Rouzbeh " <rooz7939@gmail.com> wrote in message <khv4hr$gqn$1@newscl01ah.mathworks.com>...
> hello,
>
> I am designing a gui (my first one) with guide and I'm having some problems with certain plotting (text) options. I have two sets of axes objects in my gui which are used for graphing purposes. I also have a set of check boxes corresponding to each set of axes that do simple analysis (min, max, average). when each check box is toggled on, say for the "min" of "plot1" axes, a text box gets populated by a number corresponding to the minimum value of the data and a text object printed on the graph pointing to the corresponding value on the graph.
>
> here's the code segment:
>
> In my check box callback function :
> axes(handles.Plot1);
>
> if (get(handles.Panel1Min, 'Value') == get(handles.Panel1Min,'Max')) %check toggle on
> if data1MinInd>floor((length(P1t)/2)-1)
> handles.text = text(t(data1MinInd),data1Min,['some text']);
> elseif data1MinInd<=floor((length(P1t)/2)-1)
> handles.text = text(t(data1MinInd),data1Min,['some other text']);
> end
> else
> set(handles.P1MinText,'String',''); % if toggled off, text box is cleared
> end
>
> what I'm struggling is clearing the text from the plot when the check box is toggled off.
>
> Things I have tried:
>
> 1) saving the "text" handle object everytime the toggle is on (because when it's off the handle doesn't exist), and check it agains the toggle before the conditional statements above in the check box callback function.
>
> 2) using the delete command and passing the "text" handle object as an input argument.
>
> Does the line "axes(handles.Plot1)" in anyway interfere with "text" handle assignment by making it a child?
>
> I would appreciate any help or hints that would set me on the right path to solving the problem.
>
> Thank you,
>
> Rouzbeh

Do you get an error or does the text just not clear?

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