how to do reverse plotting in MATLAB?

59 visualizaciones (últimos 30 días)
Chubeka Gcina
Chubeka Gcina el 26 de Oct. de 2020
Comentada: Elioth Daniel el 15 de Mzo. de 2023
How to do reverse plotting or reverse function in MATLAB?
  1 comentario
Adam Danz
Adam Danz el 26 de Oct. de 2020
What's that? Could you provide an example of reverse plotting or reverse function?

Iniciar sesión para comentar.

Respuestas (1)

Shubham Rawat
Shubham Rawat el 29 de Oct. de 2020
Hi Chubeka,
If you want to reverse a function you may use flip function:
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 comentario
Elioth Daniel
Elioth Daniel el 15 de Mzo. de 2023
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

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by