How change the slopes in a curve from positive to negative

조회 수: 8 (최근 30일)
Malak
Malak 2023년 7월 10일
편집: Malak 2023년 7월 10일
We hve a set of data points representing a curve.when the y value is greater than 345, for any line between two points, if the line had a positive slope we need to flip its sign and make it negative. attached is the data we are using and an image of the part of the curve that we would like to modify
Any idea how this can be done?
  댓글 수: 2
DGM
DGM 2023년 7월 10일
편집: DGM 2023년 7월 10일
Describe the specific conditions used to determine when a change should be made. Also, you appear to be plotting the data transposed (i.e. the inxb2 data is plotted on the y-axis). Is that the manner in which slope should be calculated?
Malak
Malak 2023년 7월 10일
Yes you are right I am plotting the transponse, and the slope should be calculated in this manner. I have modified the attached data to show the proper x and y data. The only specific condition is that when the y value is greater than 345 then we flip any straight line that has a positive slope to become having a negative one.

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

답변 (1개)

chicken vector
chicken vector 2023년 7월 10일
This works if you don't really care about the value on the y-axis:
load datapoints
inyb2 = -cumsum(abs(diff([0; inyb2])));
plot(inxb2,inyb2);

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by