MATLAB Answers

how to do reverse plotting in MATLAB?

17 views (last 30 days)
Chubeka Gcina
Chubeka Gcina on 26 Oct 2020
Answered: Shubham Rawat on 29 Oct 2020
How to do reverse plotting or reverse function in MATLAB?

  1 Comment

Adam Danz
Adam Danz on 26 Oct 2020
What's that? Could you provide an example of reverse plotting or reverse function?

Sign in to comment.

Answers (1)

Shubham Rawat
Shubham Rawat on 29 Oct 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

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!