interp1 issue - resampling
1 view (last 30 days)
Show older comments
variable1=[24.6944086885135;21.0998152063394;14.7533601994682;6.76823133654033;6.73000233602188;8.34930121372767;29.2864760248330;43.5413625307145;46.7782562150740;48.3839944347439];
auxvariable2=linspace(1.1,156.3,1569);
output=interp1(variable1(1:10,1),auxvariable2);
%
Hi. I got a question about interp1.
I have the data from variable1. I want to create 1569 new points using that data.
I don;t know the function, so I am using interp with 2 parameters.
I am expecting to get 1569 points, but I get 90 points and the rest until 1569 are NaN.
What am I getting wrong?
Thank you!
0 Comments
Accepted Answer
Star Strider
on 4 Nov 2022
Edited: Star Strider
on 4 Nov 2022
Try something like this —
variable1=[24.6944086885135;21.0998152063394;14.7533601994682;6.76823133654033;6.73000233602188;8.34930121372767;29.2864760248330;43.5413625307145;46.7782562150740;48.3839944347439];
v1 = 1:numel(variable1);
v2 = linspace(min(v1), max(v1), 1569);
output = interp1(v1, variable1, v2).';
szvariable1 = size(variable1)
szoutput = size(output)
figure
plot(v1, variable1, '.b', 'MarkerSize',10, 'DisplayName','Original')
hold on
plot(v2, output, '.r', 'MarkerSize',0.1, 'DisplayName','Interpolated')
hold off
grid
legend('Location','best')
figure
plot(v1, variable1, '.b', 'MarkerSize',10, 'DisplayName','Original')
hold on
plot(v2, output, '.r', 'MarkerSize',0.5, 'DisplayName','Interpolated')
hold off
grid
legend('Location','best')
xlim([4.75 5.25])
EDIT — (4 Nov 2022 at 16:38)
Added second plot for clarity.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!