I want to do the correlation of the following two plots

조회 수: 6 (최근 30일)
Devesh Yadav
Devesh Yadav 2020년 2월 23일
댓글: Star Strider 2020년 3월 18일
clc; clear all; Ts=1/200e6; t=Ts:Ts:0.00005; y=[ones(1,2000) zeros(1,8000)]; x=sin(1256e6*t+2198e10*t.^2); z=x.*y; subplot(2,1,1) plot(t,z) N=0; while N<4 t1=Ts+0.00002+0.00005*N:Ts:0.00002+0.00005*(N+1); j=@(t)x.*y; w=@(t)j(t-0.00002); subplot(2,1,2) plot(t1,w(t)) hold on N=N+1; end
  댓글 수: 2
Star Strider
Star Strider 2020년 2월 23일
This line makes no sense and throws an error:
t1=Ts+0.00002+0.00005*N:Ts:0.00002+0.00 005*(N+1);
Please learn how to format your code. Hightlght the code, then use the left-most button in the CODE tab in the toolstrip at the top to format it so it is readable.
Devesh Yadav
Devesh Yadav 2020년 2월 23일
There was a typing mistake from my side. Please check it once more

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

채택된 답변

Star Strider
Star Strider 2020년 2월 23일
Going back to using my code (because it is easier to work with):
Ts=1/200e6;
t=Ts:Ts:0.00005;
y=[ones(1,2000) zeros(1,8000)];
x=sin(1256e6*t + 2198e10*t.^2);
z=x.*y;
NR = 4; % Number Of Repeats Desired
z_extended = reshape(repmat(z(:), NR, 1), [], 1).'; % Duplicate & Convert To Vector
t_extended = linspace(Ts, max(t)*NR, numel(t)*NR); % Time Vector
figure
plot(t,z)
figure
plot(t_extended, z_extended) % Plot Original
xlim([0 max(t_extended)*1E-1])
and adding the cross-correlation:
[xc,lags] = xcorr(z, z_extended);
figure
plot(lags, xc)
grid
produces:
  댓글 수: 12
Devesh Yadav
Devesh Yadav 2020년 3월 18일
Can you please tell me the no. of computations done in this correlation :- [xc,lags] = xcorr(z, z_extended);
Star Strider
Star Strider 2020년 3월 18일
I cannot.
I doubt that would be possible to determine.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by