Convolution on a nonlinearly spaced data set.
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Splines 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!