I want to do the correlation of the following two plots

5 次查看(过去 30 天)
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);

请先登录,再进行评论。

更多回答(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