Assuming that meas.acc.data and meas.acc.time are vectors with the same number of elements, then diff on the data vector will return a numeric vector with one element fewer than the time vector, so meas.jerk.data and meas.jerk.time will likely have mismatching sizes.
One easy solution is to take the time as the mean of adjacent time points, e.g.:
I deleted my other answer because it was unlikely to give you the result that you expect.
"I dont get your answer"
Because you used diff your data vector is one element shorter than your time vector, so essentially you need to think of a way to match your time point to the new (shorter) data vector. There is no single solution to this, but something like this is easy to do:
average adjacent time points (what I showed in my answer).
ignore the first time point.
etc.
Note that I cannot tell you which to select because which method is appropriate depends on the features and properties of your data and your data analyses.
Could you maybe explain this part of the code? I didn't get it.
What makes 1:end-1? What is end and what do you mean with it?
Thanks!
I got, that my vektor is smaler then my time vektor. I got this part. How do you get the average adjacent time points? I mean could you explain this little code :) I'm really new with matlab I'm sorry
Because end is the index of the last element, end-1 is the index of the second-to-last element. Thus
meas.acc.time(1:end-1)
uses basic MATLAB indexing to return a subvector of meas.acc.time, from its first element to its second-to-last element. Thus the subvector has one fewer element than meas.acc.time, and therefore exactly the same number of elements as the output of diff.
"How do you get the average adjacent time points?"
Simply by using the definition of arithmetic mean of two values:
Compare with my answer, which has the form (vec1 + vec2) ./ 2 , where vec1 is the subvector from the first element to the second-to-last element, and vec2 is the subvector from the second element to the last element. Then these two vectors are added together (i.e. corresponding elements are summed), and then divided by two to give the arithmetic mean.
Tip: to use MATLAB you need to learn how to use indexing, and work with vectors/arrays.
Note that you do no have to use the arithmetic mean. As I wrote in my answer, only you can decide if such an averaging is appropriate, or if another type of averaging would be better.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
0 Comments
Sign in to comment.