visually time shift individual data trace within a group

7 views (last 30 days)
Hi All,
I have a query regarding time shifting of data. If, for example, I have three time traces within a single matlab plot, I can shift them individually using:
hold on; plot(x(1:end-20),y(21:end,1),'b'); plot(x(:),y(:,2),'g'); plot(x(1:end-25),y(26:end,3),'r');
Is there a faster method of visual inspection/comparison using the 'pan' button in the 'figure properties' options to move ONLY ONE trace and not all three??
I essentially want to get the best correlation you could say between the three traces by visual inspection
Thanks

Answers (2)

Walter Roberson
Walter Roberson on 6 Apr 2011
pan applies to everything in the selected axes. You could put your traces in to separate axes and pan the one you want, but it might perhaps be tricky to select the axes to pan unless you put in some kind of button to activate a particular one.

Pascal Galloway
Pascal Galloway on 15 Apr 2011
Thanks for the answer. I have opted for the original method, I'm not prepared to attempt to code a button for this, it would take me AGES! Thanks anyway.
  2 Comments
Walter Roberson
Walter Roberson on 15 Apr 2011
The button code would be fairly simple:
You would first create the axis handles ahead of time. Don't worry about their positions or properties to start with:
axishandles = [axes;axes;axes]; %three new axes
uicontrol('Style','radio','Position',LOCATIONS(1,:),'Callback',{@axonoff, axishandles(1)});
uicontrol('Style','radio','Position',LOCATIONS(2,:),'Callback',{@axonoff, axishandles(2)});
uicontrol('Style','radio','Position',LOCATIONS(3,:),'Callback',{@axonoff, axishandles(3)});
function axonoff(src, event, axhandle)
onoff = {'off','on'};
if ishandle(axhandle)
newstate = onoff{1 + get(src,'Value')};
set(axhandle, 'Hittest', newstate);
end
Then in your main program when you decide where the trace K should go on the figure, set() the Position property of axishandles(K), and when you plot() that trace, specify axishandles(K) as the parent axis for the relevant plot commands, such as
plot(axishandles(K),x,y)
Pascal Galloway
Pascal Galloway on 5 May 2011
I will feed back if I implement this code, it may be useful to others?

Sign in to comment.

Categories

Find more on Labels and Annotations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!