Error in Using interp1
4 次查看(过去 30 天)
显示 更早的评论
Hello everyone i have an array named 'x' and trying to interpolate it but i am getting an error as "Interpolation requires at least two sample points in each dimension." Here is my code;
x_1 = interp1(0:duration*44100,X,0:1:duration*44100,'linear');
I need to resize x array to (duration * 44100). Any help would be great. Thanks.
2 个评论
Geoff Hayes
2016-5-29
ugurcan - what can you tell us about duration and X? It would be interesting to know what duration is so that we can determine the range of
0:duration*44100
and how many elements are in X.
回答(2 个)
Walter Roberson
2016-5-29
That code does not show an interp1 ?
If the duration being interpolated over is the output of the ode45 call, then note that it is a vector, not a scalar.
Your X is going to be a column vector: it could make a difference to interp1 to transpose it to be a row vector.
0 个评论
Image Analyst
2016-5-30
You vectors are wrong, especially the first arg to interp1(). This works:
duration = 2;
X = audioread('guitartune.wav'); % Read sample data.
% Define how you want to resample it
resamplingVector = 1 : (duration * 44100);
% Now to the interpolation.
x_1 = interp1(1:length(X), X, resamplingVector,'linear');
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!