What is the best way to flip part of the graph about the x axis in MATLAB ?

조회 수: 18 (최근 30일)
Abdullah AlQulaibi
Abdullah AlQulaibi 2018년 4월 27일
댓글: Star Strider 2018년 4월 27일
so as stated above when I am trying to plot a graph of a wave, I want to reflect the down dips in the graph to be upwards, is there anyway of doing that directly?
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2018년 4월 27일
Can you show the shape of the graph?
Abdullah AlQulaibi
Abdullah AlQulaibi 2018년 4월 27일
as you can see the noted valley are 2 different forces that have to be added which means that they should be inverted about the red line shown as well.

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

답변 (2개)

Star Strider
Star Strider 2018년 4월 27일
편집: Star Strider 2018년 4월 27일
Multiply the y-values by -1 to ‘flip’ it. This is the best way, and one you can use with the findpeaks function to determine the ‘peaks’ from the original data and the ‘valleys’ from the inverted data.
You may want to add an offset if you want it completely above or below y=0.
  댓글 수: 2
Star Strider
Star Strider 2018년 4월 27일
Abdullah AlQulaibi’s Answer moved here —
thank you for your reply, will that help with flipping the points shown in the figure here?
Star Strider
Star Strider 2018년 4월 27일
My pleasure.
To flip them about the red line (at y=1), first subtract 1 from your signal, then multiply it by -1, then add 1 to it.
If you want everything to be above the red line at y=1, subtract 1 from your signal, then take the absolute value (the abs function), and add 1 back to it.
If ‘y’ is your signal:
y_new = 1 + abs(y - 1);
One of these should do what you want.

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


Ameer Hamza
Ameer Hamza 2018년 4월 27일
Since you want to invert about y=1 line, you can change the y variable of your data like this,
yInverted = -y+2; % +2 to bring it back to +1 after inversion
ploy(x, yInverted);

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by