How to shift a graph relative to other graph plotted on same axes in app designed by matlab app designer??
12 views (last 30 days)
Vinayak Untwale on 24 Apr 2021
Suppose i have plotted 2 graphs in on same UIAxes in matlab App.
There are two points highlighted with x=1.56 (let say x1) and other with x=3.53(let say x2).
After plotting I want to give an option which will shift the x2 to x1 i.e. whole red plot will be shifted to left by an amount of (x2-x1).
Is there any way to shift this grpah using any kinf of slider or Knob , at the same instant as the slider or knob value changes??
Or is it possible to give an option to shift this graph using slider so when slider value changes at the same instant the graph is shifted so uder can know how much graph is
shifted to left or right??
Clayton Gotberg on 24 Apr 2021
The answers here explain how to make a slider in the GUI which updates the figure whenever the slider position changes, instead of only when the user lets go of the slider.
You can link the slider value to an x offset so that one of the plots is shifted by that amount when the slider is moved. If you need to be able to grab the points in the figure window, try these answers.
Finally, if the only positions you want to allow are the actual plot and the shifted plot, why not include a switch or button instead of a slider? Those should update near-instantly and won't allow users to set anything in between the two possibilities you want.