how to do reverse plotting in MATLAB?
31 次查看(过去 30 天)
显示 更早的评论
How to do reverse plotting or reverse function in MATLAB?
1 个评论
Adam Danz
2020-10-26
What's that? Could you provide an example of reverse plotting or reverse function?
回答(1 个)
Shubham Rawat
2020-10-29
Hi Chubeka,
x = linspace(0,10);
y = sin(x);
x = flip(x); % reverse the values of x
plot(x,y)
If you want to reverse the axes then here is an example code which you may use:
ax = gca;
axes(ax)
x = linspace(0,10);
y = sin(x);
plot(x,y)
ax.YDir = 'reverse'; % for reversing the Y direction
ax.XDir = 'reverse'; % for reversing the X direction
1 个评论
Elioth Daniel
2023-3-15
The reverse command was very helpful for me. All I wanted was for my plot to start from the higher values to lower values but I was stuck trying to solve this issue for the x axis in an FTIR plot.
Thank you! @Shubham Rawat
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!