Convolution on a nonlinearly spaced data set.
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2013-6-29
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!