Scalling MATLAB Distance Velocity

Suppose I have the following two time vectors vectors
t2 = 4 4 4 5 5 5 6 6 6 7 7 7
and t1 = 1 2 3 4 5 6 7 8 9
I know the velocity is 1 m/s.
How can I scale t2 and t1? In other words, how can I set the first t2(1) = t1(1) ?

5 Comments

What is t4? Do you mean t2? Then of course you can set t2(1) = t1(1), why do you have doubts? And what does velocity have to do with it?
My guess is that it has to do with interpolation rather than "scaling", but I don't know.
T
T on 4 Mar 2013
Edited: T on 4 Mar 2013
Because once I set the first two elements of each vector equal to each other, I don't know how it will behave for sequential points.
I don't know the correct terminology. But essentially t2 and t1 are time vectors but t2 has a higher frequency of elements than t1. What's listed above is just an example for simplicity. By using velocity, I can determine the distance and match' them up. Is this possible? Perhaps it's not even necessary. But I would like to scale the time vectors together.
There is still the confusing t4 in the questions. Please, Anthony, edit the question and either fix or explain this.
Sorry.

Sign in to comment.

 Accepted Answer

If t1 and t2 are two different ranges of your time axis, then why does t2 have repeated values? And what is the name of your velocity vector that corresponds to t1? If you have that velocity vector and t1, then you can get the velocity vector interpolated for the times in t2 using interp1():
velocity2 = interp1(t1, velocity1, t2);

12 Comments

T
T on 4 Mar 2013
Edited: T on 4 Mar 2013
T2 has repeated values because the dataset was recorded at a higher frequency.
I do have one but was plannin on using the average velocity, so just a number, say 1 or 2 m/s.
Now I attempted that command with the following variables:
t1 = [1 2 3 4 5 6 7 8 9]
t2 = [4 4 4 5 5 5 6 6 6 7 7 7]
velocity1 = [ 2 2 2 2 2 2 2 2 2 ]
velocity2 = interp1(t1, velocity1, t2);
What is this suppose to do?
Then what is t2? Is it a time? Apparently not because no matter how rapidly you sample the velocity, the times will be different unless you've cast them to integer or some other mistake. Well then, is it a velocity? No, because you have two other variables for that. So what is t2?
Regardless, I can tell with certainty that your velocity2 is also going to be all 2's, because velocity 2 is and apparently there is no variation at all in the velocity, so as far as we can tell, sampling it at a different frequency should produce nothing different. It could be different, but since all we know are velocity1 at certain times, we don't know for sure.
T
T on 5 Mar 2013
Edited: T on 5 Mar 2013
Yes, t2 and t1 are both time vectors. velocity1 was taken from the data set t1 but I just averaged them. I don't have to.
T
T on 5 Mar 2013
Edited: T on 5 Mar 2013
suppose you want to measure the force being pulled on an object and you have a device to measure this force, this device would record the force / time, t2.
suppose further that there is a device within the object you are pulling that's recording time as well, t1, but it's recording at a lesser frequency. This internal device also records velocity, velocity1.
Let me ask as directly as I can: Why does t2 have repeated values?
... because t2 only shows the whole number of seconds, without the fraction part ?
T
T on 6 Mar 2013
Edited: T on 6 Mar 2013
The device records at a high frequency.
Actual data looks like:
07/25/2012 42:46.0 96.385
07/25/2012 42:46.0 -177.608
07/25/2012 42:46.0 155.481
07/25/2012 42:46.0 64.15
That's how it appears in Excel but when you click on the cell it's of the form of something like 10:28:53 AM and so on.
I may not even need the data as it is in the HH:MM:SS format, I could probably create my own interval to match the other data set in seconds (ie. 4820-4900 s)
What is the third column? The numbers seem to not be in order. Why don't you look up xlsread() and figure out how you can get whichever column you want into an array?
The third column represents force.
I have used textscan with datevec reading the second column and converted the third column to double.
I'll have to investigate xlsread...
Actually the problem is somewhat related to the following thread:
Do you know of an example that uses these commands?
[ts1 ts2] = synchronize(ts1,ts2, synchronizemethod)
[ts1 ts2] = synchronize(ts1,ts2, Name,Value)
If t2 has unique times, then the code I originally gave you will work.
T
T on 8 Mar 2013
Edited: T on 8 Mar 2013
It looks like scaling didn't get me the result I would like and I don't think synchronize would either.
I have given some thought of binning the data.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!