Moving graph along x-axis
Show older comments
Hi,
I am trying to plot 3 different vectors that showcase the same function but with different starting points from the y-axis.

Now what I wanna do is move the yellow and the red graph so they overlap with the blue one, to see wether my determined data actually is correct. I have another picture here to further show what exactly I mean:

Now I have tried to do something similar but with the y-axis but unfortunately I couldn't make it work.
What would be a clever way to move the graphs without having to change the values of the vectors?
2 Comments
Torsten
on 17 Apr 2022
Now what I wanna do is move the yellow and the red graph so they overlap with the blue one, to see wether my determined data actually is correct.
Better work with the data, not with the graphics.
Sokratis Panagiotidis
on 19 Apr 2022
Accepted Answer
More Answers (1)
Let's call your 3 data sets (x0,y0), (x1,y1), (x2,y2) where (x0,y0) are your target data points. Then I might try something like this:
x1_shifted=x1-mean(x1)+mean(interp1(y0,x0,y1));
x2_shifted=x2-mean(x2)+mean(interp1(y0,x0,y2));
Categories
Find more on Graphics Performance 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!