Clear Filters
Clear Filters

How can I add distance to signals and how can I determine the locations of signals?

3 views (last 30 days)
please
I have two sources for sending signals, where x1 represents the signal from the first source and x2 represents the signal from the second source :
where :
w1: First Angular Frequncy (rad / sec) and frequncy 40 KHZ.
W2: Second Angular Frequncy (rad / sec) and frequncy 60 KHZ.
n: Number of samples
------------------------------------------------------------------------------------------------
I have this code, how can I add the following to it?
  1. How can I add the distance to x1 and x2 and find the distance between them ?
  2. How can I find location x1 and location x2 ?
  3. Plot Magnitude of FFT with frequencies ?
Please rewrite the code correctly to get the above results.
clear all
clc
close all
% Define all the parameters.
% Frequncy for wave one(KHZ).
f1 = 40e6 ;
% Frequncy for wave two(KHZ).
f2 = 60e6 ;
% The speed of light in vacuum (m/sec).
c = 3e8 ;
% Wavelength for wave one(m).
h1 = c / f1 ;
% Wavelength for wave two(m).
h2 = c / f2 ;
% Imaginary part.
j=sqrt(-1);
% Initialize the vector to store the values.
X = zeros(1, 20);
% Make for loop (where n: number of samples).
for n = 1:20;
x1=exp(j*h1*n);
x2=exp(j*h2*n);
X(n) = x1 + x2;
end
% Compute FFT.
Y = fft(X, 256);
% Compute Magnitude FFT
Y1 = abs(Y);
plot( Y1 );
grid on
title('Magnitude of FFT Spectrum of X(N)', 'FontSize',12,'Color','k');

Answers (0)

Tags

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!