Main Content

lowpassResample

Convert signal from one sample time to another

Since R2021a

Description

[vq,vdq] = lowpassResample(t,v,tq,config) returns an interpolated vector of samples vq and their derivatives vdq from input sample times t, input sample values v, and output sample times tq. The interpolation process is defined by the parameters in config.

example

Examples

collapse all

Sample a sine wave at pi samples per cycle.

t = (0:20)*2;
v = sin(t);

Define the interpolation sample times.

tq = (0:400)*0.1;

Define the interpolation configuration.

config.OutputRiseFall = 2; %Fixed step sample interval
config.NDelay = 5;
config.SampleMode = 'fixed';
config.CausalMode = 'off';

Perform the interpolation.

[vq,vdq]=lowpassResample(t,v,tq,config);

Scatter plot the samples, plot the interpolated data, and plot the original sine wave.

scatter(t,v);
hold on;
plot(tq,vq);
plot(tq,sin(tq));
hold off;
title('Interpolated Data');
legend('samples','interpolated data','original sine wave');

Figure contains an axes object. The axes object with title Interpolated Data contains 3 objects of type scatter, line. These objects represent samples, interpolated data, original sine wave.

Plot the interpolated derivative and the original derivative.

plot(tq,vdq);
hold on;
plot(tq,cos(tq));
hold off;
title('Interpolated Derivative');
legend('interpolated derivative','original derivative');

Figure contains an axes object. The axes object with title Interpolated Derivative contains 2 objects of type line. These objects represent interpolated derivative, original derivative.

Input Arguments

collapse all

Input sample times, specified as a fixed-step or variable-step vector.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

Input sample values corresponding to the input sample times defined in t, specified as a vector.

Data Types: single | double

Output sample times, specified as a fixed-step or variable-step vector.

Data Types: single | double

Interpolation parameters, specified as a structure with fields.

FieldDescriptionValueDefault
OutputRiseFallThe 0%–100% rise/fall time of the interpolated output.Positive real scalar1e-10
NDelayNumber of rise/fall times by which the interpolated output will be delayed with respect to the input.Positive real integer1
SampleModeInput sampling mode, either fixed-step discrete time or variable-step discrete time.fixed, variablevariable
CausalModeDetermine whether you want the interpolation process to introduce delay. Select CausalMode to introduce enough delay between input and output samples in the interpolation process so that the process is strictly causal.off, onoff

Data Types: struct

Output Arguments

collapse all

Interpolated samples, returned as a vector.

Data Types: single | double

Derivative of interpolated samples corresponding to vq, returned as a vector.

Data Types: single | double

More About

collapse all

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2021a