Complex valued signal simulation
32 views (last 30 days)
Show older comments
Hi evereyone,
I have created codes to plot the cross correlation between two shifted signal as below.....But I want to create a complex-valued Matlab simulation and see the result....the codes below are only real-valued samples.
Could anyone advice how can I do it?
Thanks in advance.
- clear; clc; close all;
- fs = 5e3;
- fc = 100;
- time_vector = 0:1/fs:1;
- sig1 = sin(2*pi*fc*time_vector);
- sig2 = zeros(1,length(sig1));
- sig_tx = [sig1 sig2];
- figure(1)
- plot(sig_tx);
- sample_delay = 6e3; %change this value to observe correlator output for different amount of sample shifts
- sig_rx = circshift(sig_tx,sample_delay);
- figure(2)
- plot(sig_rx);
- r = xcorr(sig_tx,sig_rx);
- figure(3)
- plot(r);
- [~,I] = max(r);
- disp(I)
0 Comments
Answers (1)
Prachi Kulkarni
on 16 Feb 2022
Hi,
The function xcorr supports complex numbers as well. You can use it as it is for complex signals too.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!