Convolution on a nonlinearly spaced data set.

17 Ansichten (letzte 30 Tage)
Senaasa
Senaasa am 29 Jun. 2013
Hi,
I am currently trying to use conv on a data set that is nonlinearly spaced. The convolution works, the issue I'm having is reproducing the amplitude of the convolution signal. For example, if it were a linearly spaced dataset I'd use u = conv(h,f)*dt; where dt is the spacing between points.
In my case I don't have a consistent dt value since it varies. Any suggestions on how to approach this? Thanks, Charles
  2 Kommentare
Matt J
Matt J am 29 Jun. 2013
Bearbeitet: Matt J am 29 Jun. 2013
In what way does the convolution "work", as you have it so far, if you aren't yet accounting for the varying sample spacing? And is there a reason you don't just apply interp1() and resample the signals so that they are equi-spaced?
Senaasa
Senaasa am 29 Jun. 2013
It works insofar that the profile of the convolution is correct, but the amplitude is incorrect. I had been using a loop to calculate the convolution so I have a comparison. Interpolating is possible, however I wanted to use conv to try to speed up my convolutions. If I have to interpolate and add points (in this case probably several thousand), I'm not sure how much of a benefit I'd gain by using conv. I was hoping there was a cleaner way just through the implementation of conv.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 29 Jun. 2013
Like Matt J says, the usual solution is to get evenly spaced intervals using interpolation, such as interp1() or spline().
Here's a spline demo if you want to do a cubic fit between the points:
% Demo to show spline interpolation.
% Clean up / initialize
clc;
close all;
clear all;
workspace; % Display workspace panel.
% Create the original knot points.
lengthX = 10;
x = 1:lengthX;
y = rand (lengthX,1);
% Plot it and show how the line has sharp bends.
plot(x, y, '-sr', 'LineWidth', 2);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
% Use splines to interpolate a smoother curve,
% with 10 times as many points,
% that goes exactly through the same data points.
samplingRateIncrease = 10;
newXSamplePoints = linspace(1, lengthX, lengthX * samplingRateIncrease);
smoothedY = spline(x, y, newXSamplePoints);
% Plot smoothedY and show how the line is
% smooth, and has no sharp bends.
hold on; % Don't destroy the first curve we plotted.
plot(newXSamplePoints, smoothedY, '-ob');
title('Spline Interpolation Demo', 'FontSize', 20);
legend('Original Points', 'Spline Points');
% Mathworks Demo code from their Help
% x = 0:10;
% y = sin(x);
% xx = 0:.25:10;
% yy = spline(x,y,xx);
% plot(x,y,'o',xx,yy)
The input points don't need to be uniformly spaced like I did in the demo.

Weitere Antworten (0)

Kategorien

Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by