Hello,
Can someone explain how the interpolation or decimation can be used to fit the number of samples between the two signals if both the signals doesn't have the same number of samples.
Thanks.

댓글 수: 1

Gova ReDDy
Gova ReDDy 2014년 1월 9일
편집: Gova ReDDy 2014년 1월 9일
Can I know what is interpolation and decimation.And where they can be implemented.

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

 채택된 답변

Image Analyst
Image Analyst 2014년 1월 9일

0 개 추천

See this demo:
% Make signal #1
t1 = linspace(-2*pi, 2*pi, 200);
period = 1.5;
y1 = sin(2*pi*t1/period);
plot(t1, y1, 'bo-', 'LineWidth', 6, 'MarkerSize', 20);
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Make signal #2
t2 = linspace(-2*pi, 2*pi, 130);
period = 1.5;
y2 = sin(2*pi*t2/period);
hold on;
plot(t2, y2, 'ys-', 'LineWidth', 4);
% Interpolate signal 2 up to have same number of samples as signal 1
y2Interp = interp1(t2, y2, t1);
plot(t1, y2Interp, 'rd-', 'LineWidth', 2);
legend('signal 1', 'signal 2', 'signal 2 interpolated');
% Now get signal half way between the signal #1
% and the interpolated signal #2
signal3 = 0.5 * y1 + 0.5 * y2Interp;
I trust you can do the case where you want to interpolate y1 down to the lesser number of samples that y2 has - it's straightforward.

댓글 수: 6

Gova ReDDy
Gova ReDDy 2014년 1월 14일
편집: Gova ReDDy 2014년 1월 14일
Hi Image_Analyst,
The interpolation is working fine for making the samples btween two signals equal but the values of resultant signal are different from the original signal before interpolation. As my main goal is to average the two or more signals and I guess the number of values(samples) between the two should be equal for averaging.
Can I know how the decimation works. And what is your suggestion for averaging the two signals if the samples of both are not equal.
Gova ReDDy
Gova ReDDy 2014년 1월 15일
Hi IA,
can you please explain the alternate method or solution for averaging two signals if the samples of them are not equal because interpolation is making the two signals same I mean its making the both signals values equal.
Thanks.
Image Analyst
Image Analyst 2014년 1월 15일
Interpolation of a signal to some given number of elements does not make all its values equal to some other signal. I've never heard of decimation, except when talking of catastrophes.
Gova ReDDy
Gova ReDDy 2014년 1월 16일
편집: Gova ReDDy 2014년 1월 16일
But when I applied interpoltion it is making the resultant signal same as the other as below (The both signlas data(s1 and s2) is attached)
%------s1 interpolation with s2----------%
s1_inter=interp1(s1(1,1:length(s1)), s1,s2(1,1:length(s2)));
plot(s1);hold on;plot(s2,'-g');plot(s1_inter,'-r');
for the resultant interpolated signal some of them are not available.
%------s2 interpolation with s2----------%
s2_inter=interp1(s2(1,1:length(s2)), s2,s1(1,1:length(s1)));
plot(s1);hold on;plot(s2,'-g');plot(s2_inter,'-r');
The resultant interpolated signal is same as the other signal.
Can I know if there is something wrong with the implementation itself or soemthing else.
Otutput:
thanks.
Image Analyst
Image Analyst 2014년 1월 16일
You're not using interp correctly - look at the first two input arguments - they are the same and they should not be.
Gova ReDDy
Gova ReDDy 2014년 1월 16일
편집: Gova ReDDy 2014년 1월 16일
Thanks IA ,
And if I am not wrong then the correct way should be the below and yes as you said,it is not giving the same values for both signals
Here the s1 samples< s2
s1_inter=interp1(1:length(s1), s1,1:length(s2));
%%It is adding Nan values from the length of s1 to the length of s2 making the samples in (or the length of) both same.%%
s2_inter=interp1(1:length(s2), s2,1:length(s1));
%%It is clipping off the values from length of s1 to the length of s2 making the samples in (or the length of) both same%%

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

추가 답변 (0개)

카테고리

제품

질문:

2014년 1월 9일

편집:

2014년 1월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by