Find X of corresponding Y which is manipulated?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sagar Dhage
le 16 Juil 2014
Commenté : Andrei Bobrov
le 16 Juil 2014
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 commentaires
Réponse acceptée
Andrei Bobrov
le 16 Juil 2014
Modifié(e) : Andrei Bobrov
le 16 Juil 2014
[~,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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!