how to do reverse plotting in MATLAB?

조회 수: 15 (최근 30일)
Chubeka Gcina
Chubeka Gcina 2020년 10월 26일
댓글: Elioth Daniel 2023년 3월 15일
How to do reverse plotting or reverse function in MATLAB?
  댓글 수: 1
Adam Danz
Adam Danz 2020년 10월 26일
What's that? Could you provide an example of reverse plotting or reverse function?

댓글을 달려면 로그인하십시오.

답변 (1개)

Shubham Rawat
Shubham Rawat 2020년 10월 29일
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
Elioth Daniel
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 CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by