cubic spline interpolation and upsample ?

조회 수: 9 (최근 30일)
Eren Çiftçi
Eren Çiftçi 2017년 1월 14일
댓글: Charalambos Hadjipanayi 2021년 12월 17일
Write down a routine which upsamples the recorded speech by M and uses
cubic spline interpolation on the data to replace the zero samples. Cubic spline
interpolation routines exist in MATLAB toolboxes. You can use lookfor
command of MATLAB to find out how to do it. Then play the upsampled data
for M = 2 and comment on the effect of upsampling in terms of frequency
changes.
[y,Fs]= audioread('sound.wav');
Y=upsample(y,2)
I did the upsampling but couldn't figure out cubic spline interpolation.
  댓글 수: 2
John D'Errico
John D'Errico 2017년 1월 14일
What did you find when you tried this:
lookfor spline
Why did you not try that?
Eren Çiftçi
Eren Çiftçi 2017년 1월 14일
I tried
lookfor spline
but around 50 codes apear and I don't know which to use for my assigment

댓글을 달려면 로그인하십시오.

답변 (3개)

Star Strider
Star Strider 2017년 1월 14일
편집: Star Strider 2017년 1월 14일
Consider that you were told to ‘resample’ your signal, so you should be searching on ‘resample’, not ‘spline’. You will find the resample function, and particularly the method argument section that should guide you to the solution you want.
EDIT Note that the resample function incorporates a FIR anti-aliasing filter. This is absolutely necessary for signal processing applications. Interpolation without the anti-aliasing filter will not produce reliable results for signal processing purposes.
  댓글 수: 1
Charalambos Hadjipanayi
Charalambos Hadjipanayi 2021년 12월 17일
Why do you need the anti-aliasing filter if you are up-sampling? Doesn't aliasing occur when you downsample?

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2017년 1월 14일
See my spline demo:
% 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)
slopes = [0, diff(smoothedY)];
plot(newXSamplePoints, slopes, 'k-', 'LineWidth', 3);
% Draw x axis
line(xlim, [0,0], 'Color', 'k', 'LineWidth', 2);
grid on;
legend('Original Points', 'Spline Points', 'Slope');
  댓글 수: 4
Eren Çiftçi
Eren Çiftçi 2017년 1월 16일
편집: Eren Çiftçi 2017년 1월 16일
well it is not actually two points(it is 76160 points) I just write like that to show what I am trying to do.
Image Analyst
Image Analyst 2017년 1월 16일
So what's the problem? Just replace my data with your data in my code. Did you do that?

댓글을 달려면 로그인하십시오.


kevin cobley
kevin cobley 2017년 2월 28일
편집: kevin cobley 2017년 2월 28일
try 'interp1("original sampletimes","samples","new sample times")'
thats it.. (but you should understand how spline interpolation works, and its relation to matrix algebra... search youtube for cubic spline interpolation - its beautiful stuff..)
  댓글 수: 2
N/A
N/A 2021년 12월 13일
is there a function for polynomial interpolation
Image Analyst
Image Analyst 2021년 12월 13일
Cubic spline is a polynomial interpolation using third order polynomials.
Maybe you could try to do a linear upsampling to get more points, and then use sgolayfilt() if you want some different order.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by