Matlab: how to write a vector of a few points as a continuous function? -
i have 2 vectors:
x = [0; 1; 2] y = [2.0000; 0; -14.7781]
if plot x , y see 3 points on xy
-plane. want connect 3 points , them continuous function:
y = f(x), y(0) = 2; y(1) = 0; y(2) = -14.7781; y(0.5) = value between 2 , 0.
for example y
can treated zoh (zero order held) continuous signal.
i saw matlab has function called d2c
, converts model discrete continuous time. have no idea how link vector have already. how matlab?
ok, latest edit improves situation lot.
however, still not demarcate problem sufficiently.
zoh simple
>> x = [0; 1; 2]; >> y = [2.0000; 0; -14.7781]; >> f = @(new_x) y(find(x <= new_x, 1, 'last')); >> f(0.5) ans = 2
however, not think mean, y(0.5) = value between 2 , 0
part of question indicates.
perhaps want linearly interpolated value:
>> f = @(new_x) interp1(x,y, new_x); >> f(0.5) ans = 1
or cubic splines interpolation:
>> f = @(new_x) interp1(x,y, new_x, 'spline'); >> f(0.5) ans = 2.5973
what i'm asking is: model best describes signal when sample time decrease infinitesmal values?
Comments
Post a Comment