Using interp2 function on a 2-dimensional sine wave
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have tried using the interp2 matlab function to interpolate a 2-dimensional sine wave.
Is this the result I should expect? Is there any way to compare the differences between the interpolated output to the original waveform?
Here's how the program goes:
% 2-dimensional interpolation
%original waveform
Fs=130; %sampling frequency
xi=(0:63); yi=(0:63);
[Xi,Yi]=meshgrid(xi,yi); % 64 samples
Z0 = sin(2*pi*30/Fs*Xi) + cos(2*pi*20/Fs*Yi);
%reduce sampling freq by 2 times
Fi=Fs/2; %sampling frequency/2
x=(0:63); y=(0:63);
[X,Y]=meshgrid(x,y); % 64 samples
Z = sin(2*pi*30/Fi*X) + cos(2*pi*20/Fi*Y);
Zi=interp2(xi,yi,Z,Xi,Yi,'bicubic');
%plot original waveform figure(1) surf(Xi,Yi,Z0); xlabel Xi ylabel Yi grid on title 'Original waveform'
%plot waveform on sample grid figure(2) surf(Xi,Yi,Z); xlabel X ylabel Y grid on title 'Original waveform on sample grid'
%plot Interpolated waveform figure(3) surf(xi,yi,Zi); xlabel xi ylabel yi grid on title 'interpolated waveform'
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!