Effacer les filtres
Effacer les filtres

Truncating Y values during integration to integrate only the "peaks" or delete CERTAIN elements from a matrix

3 vues (au cours des 30 derniers jours)
I have a load of data from a force transducer output. The data is in the form of time vs volts.
TEXT=fopen('Test 5.txt','rt');
texta=textscan(TEXT,'%f%f','CommentStyle','"');
A=texta{1};
B=texta{2};
C=[A,B];
D=C;
plot(D)
The first part of my script removes the -ve values, as this relates to the compression wave recoiling in the force transducer and doesn't actually relate to compressive forces at all.
C(C<0)=0;
plot(C)
So far so good.
I am measuring the peak impulse above a certain range — impulse being the integral of force*time (or volts*time in this instance as the transducer outputs a voltage and I haven't included the conversion yet).
To measure the peak impulse I only need the values above a certain range, say 1.
I have tried to simply make a conditional statement to remove all data less than 1:
E=C;
E(E<1)=0;
plot(E)
However, this is not correct as what I am after is more like this (edited on MS paint):
Does anyone have any ideas on how I can, either:
  • Limit the Y values used to numerically integrate the data i.e ymin=1
  • Remove the data in such a fashion as to resemble the final image above?
Any help would be appreciated!!! Mark.
EDIT:
Please note that I cannot simply state that E(E<1)=1 as this would artificially inflate the integral. I need all the data below that point to basically disappear.

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 18 Nov 2013
findpeaks(y,'minpeakheight',1)
  3 commentaires
mark
mark le 18 Nov 2013
Hey Azzi,
It is able to take out values of y above 1 but it fails to take the X values too.
Say a force parabola (peak) is bounded within 0.1s, it will only plot the parabola force (i.e the line) vs a row value. If there are 100 points defining the curve it'll plot the Y values vs X values going from 0->100. It should take the corresponding time interval that the peak lies within.
As you can see in the above output, there are over 800 points that define data points above 1 but it hasn't indicated the total time over which this should occur.
  • How do you get matlab to output the corresponding X values?
  • Is there really no way to just tell matlab to integrate the area under the curve starting from this value?
cheers, Mark.
Azzi Abdelmalek
Azzi Abdelmalek le 18 Nov 2013
Modifié(e) : Azzi Abdelmalek le 18 Nov 2013
[x_peak,x_location]=findpeaks(y,'minpeakheight',1)
to integrate the area under the curve, use trapz function

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by