how can find a point from an array where the points it follows start to decrease
1 次查看(过去 30 天)
显示 更早的评论
i have array contains points, somehow it exist a part of this array where are decreasing ,how can i find this part, i really need a help
0 个评论
采纳的回答
MHN
2016-2-17
Assumption : there is on only one decreasing region in your data points.
x = -2:0.1:6;
y = x.^3-5*x.^2+5*x-2;
D = diff(y);
decreaseStart = find(D<0,1,'first');
decreaseEnd = find(D<0,1,'last');
plot(x,y)
hold on
plot(x(decreaseStart:decreaseEnd),y(decreaseStart:decreaseEnd),'r');
0 个评论
更多回答(2 个)
Azzi Abdelmalek
2016-2-17
%Example
t=0:0.1:20
y=sin(t)
plot(t,y)
%---------------------
ii=diff(y)>0
jj=strfind(ii,[1 0])
tout=t(jj)
yout=y(jj)
0 个评论
Jos (10584)
2016-2-17
A decrease is where an element is smaller than the element before it.
A = [1 2 3 4 3 2 1]
changeInA = diff(A)
isDecreasing = changeInA < 0
whereDecreasing = find(isDecreasing) % perhaps add 1 to this
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!