Prev: Using ginput along with pushbuttons in Matlab GUI
Next: Please Some Help With My Frenet-Serret Function
From: Abdullah on 6 Jan 2010 15:10 Hi all, I have an array that have two column vectors ranging 1-201. the first column contains time series t=0:0.01:2; the 2nd column contains a trajectory i.e arr=[t trajectory]; I want to expand this array for t1=0:0.01:4; and make a new array newarr=[t1 decompressed_trajectory]; so that the trajectory is decompressed time wise and the graph of the trajectory is such that it has been pulled from both ends. Is it possible??
From: Alan B on 6 Jan 2010 15:45 "Abdullah " <abdullahumer(a)yahoo.com> wrote in message <hi2qne$l93$1(a)fred.mathworks.com>... > Hi all, > > I have an array that have two column vectors ranging 1-201. the first column contains time series > t=0:0.01:2; > the 2nd column contains a trajectory i.e > arr=[t trajectory]; > > I want to expand this array for > t1=0:0.01:4; and make a new array > newarr=[t1 decompressed_trajectory]; > so that the trajectory is decompressed time wise and the graph of the trajectory is such that it has been pulled from both ends. > Is it possible?? The concept of "decompressing a trajectory" doesn't mean anything to me. By "decompress" do you mean you want to scale the data in the time dimension? That can be done with interp1(). Or do you want to extrapolate? If you don't have a model for your trajectory, then you can just make up random data and append it to the end of your vector. If you have a model for your trajectory, you can estimate model parameters and then extrapolate. If the model is polynomial (eg parabolic or linear) then this can be done easily using polyfit() and polyval(). If you want to use a spline fit, you can use interp1() with the 'extrap' option.
From: ImageAnalyst on 6 Jan 2010 20:23 As I understand it, you basically want to make that array (curve) have more samples in it. To do this you use interp1(). You pass in an array with the number of samples you want. Do this for both column 1 and 2 (might have to do them separately). It's not clear that when you said you wanted to stretch the time axis if you just wanted more sample or if you also wanted the numbers to be different. If you want your time scale to be different numbers, then just multiply by a scaling factor. For example your time went from 1 to 42 before interpolation in 42 steps, and now it goes from 1 to 42 in 420 steps but if you want it to go from 1 to 840 (or whatever) then you just multiply by 20 and now it will go from 20 to 840 in 420 steps.
From: Abdullah on 6 Jan 2010 22:44 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <fdb25f80-47ad-44df-bea8-c553631d66c8(a)q16g2000vbc.googlegroups.com>... > As I understand it, you basically want to make that array (curve) have > more samples in it. To do this you use interp1(). You pass in an > array with the number of samples you want. Do this for both column 1 > and 2 (might have to do them separately). > > It's not clear that when you said you wanted to stretch the time axis > if you just wanted more sample or if you also wanted the numbers to be > different. If you want your time scale to be different numbers, then > just multiply by a scaling factor. For example your time went from 1 > to 42 before interpolation in 42 steps, and now it goes from 1 to 42 > in 420 steps but if you want it to go from 1 to 840 (or whatever) then > you just multiply by 20 and now it will go from 20 to 840 in 420 > steps. I want to scale it in time. The trajectory is in degrees. It starts from 90 deg, goes to 70 deg in 0.2 sec and from 70 deg to 180 in 1.3 sec making a smooth curve. The whole trajectory is 1.5 sec. It was 2 sec but I reduced it to 1.5 sec because it is constant after 1.5 sec. Now I want the same trajectory but in different times. The new trajectory must be from 90-70 deg in 0.4 sec and from 70-180 in 2.6 sec. The trajectory is an array not a polynomial. I have to tried to make a polynomial but it didn't help because the polynomial can't make the exact shape of the trajectory. What should I do for this? I s there any builtin command.
From: ImageAnalyst on 6 Jan 2010 23:39 OK, like I thought. So how did interp1 work for you? Where's your code? Any error message? You need to put some work into this because I'm taking off for the night. If I remember, I'll look at your code tomorrow.
|
Next
|
Last
Pages: 1 2 3 4 Prev: Using ginput along with pushbuttons in Matlab GUI Next: Please Some Help With My Frenet-Serret Function |