how to get time-speed function from distance-speed function, numerical?

44 Views Asked by At

I have speed function depends on distance. Actually, numerical connection. $v = v(s)$, so i have $[ s_i, v_i ]$ values. But I want to get speed function depens on time ( $v=v(t)$ )

time and distance: $ s = s_0+\int_{0}^t v(t)dt $

how to get numerical values of $[t_i, v_i]$

note: there no problem with numerical integral and differantiation.

EDIT: I have tried this matlab script for $t = t_0 + \int_{0}^s {1 \over v(s)}ds$ (came from ${ds \over dt} = v$)

s = linspace(0,400); % I will determinate for this set.
v = V_s(s);  % V_s(s) function is not aritmatical but interpolation function.
% I have [s, v] numerical values. 

t = zeros(size(s));
for i=1:length(t)-1;
    upper = ( s(i+1)-s(i) ) / v(i+1); % ds/v
    lower = ( s(i+1)-s(i) ) / v(i); % ds/v
    %may be correct finite differantial element is:
    correct = ( upper + lower ) / 2;
    %my t values, with numerical integration
    t(i+1) = t(i) + correct;
end

%now, I have [s, t] numerical values.
%i can touch [v(s), t], so [v, t] numerical values

plot(s,v); %distance-speed graph
plot(t,v); %time-speed graph