Find X of corresponding Y which is manipulated?
1 回表示 (過去 30 日間)
古いコメントを表示
i need to extract the exact values where the increasing and decreasing trend starts.
I have Fx (column vector) and corresponding T values (column vector). step 1: the values which are less than 100, converts into 0
Fx(Fx <100)= 0;
step2: Fx(diff(Fx)==0) = []; % delete the element which is repeating
step3:B = [0; diff(Fx)]; %difference between element It will start with the first element in the matrix and then report the difference between that and the next element. There's no leading element before the first one so is just truncates the matrix by one element. We add a zero because there is no change there as it's the starting element.
step4: Result = find(B(1:end-1).*B(2:end)<0); This will return the index where you are on the cusp of the inflection. In this case it will be.
step5: New_Fx=Fx(Result); gives the Fx values where trends get changed
Now how to find corresponding T values? I tried New_T=T(New_Fx); but not it showing wrong T values. I think we have removed the elements in Fx which are repeating but not corresponding T values.
How to find these T values to corresponding New_Fx?
complete code is: Fx(Fx <100)= 0;
Fx(diff(Fx)==0) = [];
B = [0; diff(Fx)]; Result = find(B(1:end-1).*B(2:end)<0); New_Fx=Fx(Result);
0 件のコメント
採用された回答
Andrei Bobrov
2014 年 7 月 16 日
編集済み: Andrei Bobrov
2014 年 7 月 16 日
[~,i1] = findpeaks(Fx);
[~,i2] = findpeaks(-Fx);
out = T(sort([i1;i2]));
without findpeaks:
ll = find([true;diff(Fx)~=0]);
F = Fx(ll);
b = diff(F);
lll = [false;b(1:end-1).*b(2:end)<0;false];
out = T(ll(lll));
ADD
complete code:
x = xlsread('book3.xlsx');
xx = x(:,2);
xx(xx <100)= 0;
[~,i1] = findpeaks(xx);
[~,i2] = findpeaks(-xx);
out = x(sort([i1;i2]),1);
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!