From: Nuri on
Hi,

I asked this before and searched a lot of times but i couldn't find a solution.

My want to plot 3 graphs and change one of them's value with a slider. But each time I use the slider to change the value, it plots another graph and keeps the old ones (like this: http://i40.tinypic.com/2uelhcl.jpg).

Here is my files: http://duckload.com/download/465993/untitled.rar

I will be very happy if anyone can fix it or give me an example file. Thanks for your help.

Regards
From: Nuri on
any help?
From: Sadik on
Hi Nuri,

What you should do is find the handle of the green line you would like to move.

The way to do it is the following:

1. When you plot the green line the first time, in your slider1_CreateFcn, keep its handle by

lineHandle = plot(... % your green line plot.

2. Then carry this on to your other callbacks by putting it into the handles structure:

handles.greenLine = lineHandle;
guidata(hObject, handles);

3. Now, in slider1_Callback, retrieve this handle:

lineHandle = handles.greenLine;

4. Once you do that, you can now modify the xData and yData properties of your line using the variable lineHandle. Something like:

% new values according to slider value
newXData = ...
newYData = ...
set(lineHandle,'xData',newXData,'yData',newYData);

This way, you are updating the data of your line, rather than making a new line.

Best.
 | 
Pages: 1
Prev: need help with arrays
Next: Use filename