Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
What I have here are two measured displacements over the same time with an equal interval of 1 second. Both oscillations tend to approach the resting asymptote, which is the same for both. The first one at the end of measurement didnt manage to approach, but the second did.
For my task, I had to find periods and amplitudes of oscillations. To get periods, I simply used the difference between two interceptions of oscillation with asymptote via root() function. One of the arguments for this function is a guess points between which this interception should be met. For those points I pick local extremas (or peaks shortly). To get them, I need to know the first derivative of the oscillation function and look for the points where derivative becomes zero. But in my case, I have only empirical data, which I have to use to get proper constants a and w for the oscillation equation.
Based on this, I created splines for both data sets, and started taking derivatives to find a slope.
To get local extremas, I used lookup() func (it cannot work with range, had to use vector form as inputs) to get the points where slope is almost equal to zero. As a result of discrete vector usage, I got multiple points of peak in each extrema, had to pick the most distant from the asymptote and remove others. For that purpose I created a custom trimmer() function which did a good job with the first data set, but fails with the second, where oscillations almost approached asymptote.
It seems that after trimming, all of residual untrimmed points tend to be on the right side of the actual peak. Because of that, my interception evaluation (that one with root() func) for second data set fails.
Can someone share their ideas on why it happens and how to fix that?
Legacy Mathcad 15 M050
Solved! Go to Solution.
Hi
Said I was working on the amplitude of the oscillations and have an answer.
you can now use genfit() to fit the equation of the curve with these data points.
Cheers
Terry
Hi
I have used the fft() function in Mathcad to obtain the peak period and frequency of the oscillations. You can get the maximum and minimum displacement from the "cs1" spline easily with max(cs1) and min(cs1) functions. Greater accuracy can be gained by using more points but for fft() they must be multiples of 2n.
I know this does not get the displacements of the lesser peaks but am working on this.
Wow, I did not thought and did not even know that Fourier transform can be applied in my situation! I will try your method in couple of hours to check how it behaves with second data set.
But as you mentioned, for my task I need to get each peak (at least only the reasonable ones)
And as I said it original post, the first data set is fine, all my calculations gave expected result, but the second one...
On that part, where magnitude gets smoller and smoller, starting with 5th peak (between 12s and 13s), trimmer func became an one-eye blind man and missed half of the nodes.
Anyway, really appreciate your effort. In case you get some progress (or not), would be glad if you tell about it
but am working on this.
Is the data in column #1 and #2 really supposed to follow the function type
given that column #0 is t ??
I may be wrong but I doubt it that this function could create the data given.
Well, I can neither approve, nor deny that. You see, for this laboratory work (I am a student) I had to do several calculations in order to get the data using special program with preset parameters, that simulates this oscillations. But because I study on-line at the moment, and as we dont have an access to this program, we were provided with already measured data. That formula, if we trust the manual to this task, is exactly the one that was used for that data, but I cannot even check if this is true. Picture attached (sorry for cyrillic, its in ukrainian)
I was asking because I tried to determine the parameters of this function given the measured data.
But I had no luck as you can see below. The limit 4 (factor K) was calculated pretty nice, but frequency omega and alpha could not be determined to make a nice fit.
I combined K and Xin into a single factor K. Of course, I also tried different guess values -but without success.
I also played around changing the values for K, alpha and omega manually but could not find a suitable fit - the amplitudes came out much to high.
But once I added a scaling factor for the amplitude a nice fit could be achieved.
So that was the reason why I doubted that the measurement data originated from a process that could be modeled using the equation provided. But maybe Xin is not a constant as I assumed but rather a function dependent on t -> Xin(t) ?
Nonetheless I am attaching my worksheet for whatever it may be worth.
Hi
Said I was working on the amplitude of the oscillations and have an answer.
you can now use genfit() to fit the equation of the curve with these data points.
Cheers
Terry
Werner, Im actually impressed!
I knew about genfit(), but I've got some bad experience using it, so I didnt even try.
But maybe Xin is not a constant as I assumed but rather a function dependent on t -> Xin(t) ?
Nope, Xin is a variable (changing which will obviously lead to other data from that equation) and is called "input disturbance of the system" if to be specific, so definitely not a function of "t".
And yes, your words about mistake in equation are possibly true, because applying known constants (K*Xin = 4, w = 1/sec) and guessing possible expected variables T1 and T2 for a evaluation - it gave me the waves as it should, but with amplitudes that x100 times away from the expected ones (you also mentioned that in your reply). So yes, I now also think that a scale constant should be present, or maybe it needs more precise value for a constant that can be calculated from possible another equation..
Given that the derivatives of both Xout functions (the original one and mine with the added scale factor) are basically just multiples of sin(omega*t) the maxima are at multiples of 2 pi /omega and the minima at pi + multiple +f 2 pi /omega.
So once the frequency omega is found calculating the extrema should be quite easy.
Given that my modified function gets pretty good fits we can use the omegas from there - actually both are very near to 1 which is possibly the value used when creating the data (as well as K=4 and not K=3.999999...)
EDIT: Also Terry found by other means a value (Ttrial=6.282 s) which correspond perfectly to 2 pi /omega with omega=1.
Here for the data column #2:
MC15 file attached
once the frequency omega is found calculating the extrema should be quite easy.
Given that my modified function gets pretty good fits we can use the omegas from there - actually both are very near to 1 which is possibly the value used when creating the data
indeed, omega is 1, because of equation w = 2p/Tn, where Tn is a period, which by my calculation is equal to 6.283 sec (which is exactly 2p*sec), so w = 1/sec.
Once again, thank you for your time and effort, you helped a lot and even more, I learned something new thanks to your replies. I will use your method as one of the possible approaches to the task.
And also will use one that @terryhendicott provided. I would like, if you are okay with that, to mark his reply as solution, because his one is more general and universal, especially in cases when we dont have even a hint about a form of equation that models that oscillations.
Also want to thank him for his effort. You both helped me a lot. I appreciate it!
You're welcome, and good luck with your studies!
