From: Abdullah on
"Abdullah " <abdullahumer(a)yahoo.com> wrote in message <hi4a7h$8ic$1(a)fred.mathworks.com>...
> "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hi46qp$pre$1(a)fred.mathworks.com>...
> > Dear Abdullah!
> >
> > > I was using interp1 wrong but i corrected it then. interp1 is for interpolation. Predicting unknown values from known values. It just changes the sampling rate. I don't want to do that.
> >
> > The problem is getting less clear to me again.
> > You do *not* change the sampling rate but want the same curve with a different number of time ticks?!
> > Do you want to apply 2 different changes of the sampling rate for the 2 different parts of the curve?
> > Do you want to use INTERP1 to determine the new time points?
> >
> > Perhaps you can create some short example values with about 10 time points?
> >
> > Kind regards, Jan
>

> Hi, Thanks for your kind reply.
>
> Yes I don't want to change the sampling rate. I want to scale the array in time. Total array is 1.5 sec with time step of 0.01. I want to change it to 3 sec with the same time step.


I'm stuck in this thing. Hope someone could find a solution.
From: Steven Lord on

"Abdullah " <abdullahumer(a)yahoo.com> wrote in message
news:hi4a7h$8ic$1(a)fred.mathworks.com...
> "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message
> <hi46qp$pre$1(a)fred.mathworks.com>...
>> Dear Abdullah!
>>
>> > I was using interp1 wrong but i corrected it then. interp1 is for
>> > interpolation. Predicting unknown values from known values. It just
>> > changes the sampling rate. I don't want to do that.
>>
>> The problem is getting less clear to me again.
>> You do *not* change the sampling rate but want the same curve with a
>> different number of time ticks?!
>> Do you want to apply 2 different changes of the sampling rate for the 2
>> different parts of the curve?
>> Do you want to use INTERP1 to determine the new time points?
>>
>> Perhaps you can create some short example values with about 10 time
>> points?
>>
>> Kind regards, Jan
>
> Hi, Thanks for your kind reply.
>
> Yes I don't want to change the sampling rate. I want to scale the array in
> time. Total array is 1.5 sec with time step of 0.01. I want to change it
> to 3 sec with the same time step.

So you have t = 0:0.01:1.5; and f which is the value of your "function" at
those times.

Let t2 = 2*t -- now t2 goes from 0 to 3 in steps of 0.02, and f is the value
of the "new function" at those times. Is this what you intended? If so,
now interpolate t2 and f at t3 = 0:0.1:3 to obtain f3, the values of your
"function" at the times in t3.

If instead you're trying to take t and f and _extrapolate_ the value of the
function out to t = 3, that's probably a Bad Idea unless you _know_ your
function is "well behaved"; one of the reasons is given in one of John
D'Errico's favorite Mark Twain quotes:

http://en.wikiquote.org/wiki/Life_on_the_Mississippi

"In the space of one hundred and seventy-six years the Lower Mississippi has
shortened itself two hundred and forty-two miles. That is an average of a
trifle over one mile and a third per year. Therefore, any calm person, who
is not blind or idiotic, can see that in the Old O�litic Silurian Period,
just a million years ago next November, the Lower Mississippi River was
upwards of one million three hundred thousand miles long, and stuck out over
the Gulf of Mexico like a fishing rod. And by the same token any person can
see that seven hundred and forty-two years from now the Lower Mississippi
will be only a mile and three quarters long, and Cairo and New Orleans will
have joined their streets together, and be plodding comfortably along under
a single mayor and a mutual board of aldermen. There is something
fascinating about science. One gets such wholesale returns of conjecture out
of such a trifling investment of fact.
-- Ch. 17"

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Abdullah on
"Steven Lord" <slord(a)mathworks.com> wrote in message <hi4t05$sdj$1(a)fred.mathworks.com>...
>
> "Abdullah " <abdullahumer(a)yahoo.com> wrote in message
> news:hi4a7h$8ic$1(a)fred.mathworks.com...
> > "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message
> > <hi46qp$pre$1(a)fred.mathworks.com>...
> >> Dear Abdullah!
> >>
> >> > I was using interp1 wrong but i corrected it then. interp1 is for
> >> > interpolation. Predicting unknown values from known values. It just
> >> > changes the sampling rate. I don't want to do that.
> >>
> >> The problem is getting less clear to me again.
> >> You do *not* change the sampling rate but want the same curve with a
> >> different number of time ticks?!
> >> Do you want to apply 2 different changes of the sampling rate for the 2
> >> different parts of the curve?
> >> Do you want to use INTERP1 to determine the new time points?
> >>
> >> Perhaps you can create some short example values with about 10 time
> >> points?
> >>
> >> Kind regards, Jan
> >
> > Hi, Thanks for your kind reply.
> >
> > Yes I don't want to change the sampling rate. I want to scale the array in
> > time. Total array is 1.5 sec with time step of 0.01. I want to change it
> > to 3 sec with the same time step.
>
> So you have t = 0:0.01:1.5; and f which is the value of your "function" at
> those times.
>
> Let t2 = 2*t -- now t2 goes from 0 to 3 in steps of 0.02, and f is the value
> of the "new function" at those times. Is this what you intended? If so,
> now interpolate t2 and f at t3 = 0:0.1:3 to obtain f3, the values of your
> "function" at the times in t3.
>
> If instead you're trying to take t and f and _extrapolate_ the value of the
> function out to t = 3, that's probably a Bad Idea unless you _know_ your
> function is "well behaved"; one of the reasons is given in one of John
> D'Errico's favorite Mark Twain quotes:
>
> http://en.wikiquote.org/wiki/Life_on_the_Mississippi
>
> "In the space of one hundred and seventy-six years the Lower Mississippi has
> shortened itself two hundred and forty-two miles. That is an average of a
> trifle over one mile and a third per year. Therefore, any calm person, who
> is not blind or idiotic, can see that in the Old Olitic Silurian Period,
> just a million years ago next November, the Lower Mississippi River was
> upwards of one million three hundred thousand miles long, and stuck out over
> the Gulf of Mexico like a fishing rod. And by the same token any person can
> see that seven hundred and forty-two years from now the Lower Mississippi
> will be only a mile and three quarters long, and Cairo and New Orleans will
> have joined their streets together, and be plodding comfortably along under
> a single mayor and a mutual board of aldermen. There is something
> fascinating about science. One gets such wholesale returns of conjecture out
> of such a trifling investment of fact.
> -- Ch. 17"
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>

Hi Steve, thanks for your reply.

> Let t2 = 2*t -- now t2 goes from 0 to 3 in steps of 0.02, and f is the value
> of the "new function" at those times. Is this what you intended? If so,
> now interpolate t2 and f at t3 = 0:0.1:3 to obtain f3, the values of your
> "function" at the times in t3.

I did understand what you said, and this is what I want but the problem is that i don't have a "function" f(t) so that i can find f(2*t) and then interpolate it with time step that I want. The data that I have is in array, not a function.
Thank you.
From: ImageAnalyst on
On Jan 7, 1:29 am, "Abdullah " <abdullahu...(a)yahoo.com> wrote:
> I have a two column array of trajectory. 1st column contains time
> t=0:0.01:1.5;
> arr=[t trajectory];
> 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.
> The new trajectory must be from 90-70 deg in 0.4 sec and from 70-180 degrees for the rest of the time.
>
> t1=0:0.01:3;
> arr=[t1 new_trajectory];
>
> what should I do with trajectory to get new_trajectory??
> new_trajectory= ????


---------------------------------------------------------------------------------------------------------------------
Abdullah :

Well then that's easy. Just simply multiply t by 2 to get the new
time scale. Simple as that. You will have the same number of sample
points as before. Copy and paste this solution and you'll see that it
works as you want:

clc;
clear all;
close all;
workspace;
% y = linspace(a,b,n) generates a row vector y of n points linearly
spaced between and including a and b.
t=0:0.01:1.5
% Generate some sample data
firstPart = linspace(90, 70, 21);
secondPart = linspace(70, 180, 130);
trajectory = [firstPart, secondPart];
% Now we have some sample data. It may not exactly match the shape
that Abdullah has but that doesn't matter.
% Plot it
subplot(2,1,1);
plot(t, trajectory, 'r-o');
ylim([0 180]);
grid on;
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.

% Now, "The new trajectory must be from 90-70 deg in 0.4 sec
% and from 70-180 degrees for the rest of the time."

timeScale2 = 2 * t % KEY PART RIGHT
HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

% Plot it
subplot(2,1,2);
plot(timeScale2, trajectory, 'r-o');
ylim([0 180]);
grid on;
From: Jan Simon on
Dear Abdullah!

> Yes I don't want to change the sampling rate. I want to scale the array in time. Total array is 1.5 sec with time step of 0.01. I want to change it to 3 sec with the same time step.

If you have an array for 1.5 sec with a time step of 0.01, you have 151 time points. If you want an array for 3.0 sec with the same time step, you get 301 time steps. Because the second array is longer, you *do* need an interpolation of the corresponding values.

I'm aware, that you repeatedly state, that you do not need an interpolation. But you exactly describe an interpolation operation again and again. Can you define the difference between your needs and an interpolation (e.g. linear or nearest neighbor)?
Or please give us an example with a few number of time points:
Original values for time points 0:0.1:1.5
Wanted values for time points 0:0.1:3.0

Kind regards, Jan