Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

please correct my matlab code

Status
Not open for further replies.

hitman1988

Member level 5
Joined
Nov 17, 2009
Messages
83
Helped
5
Reputation
10
Reaction score
4
Trophy points
1,288
Location
iraq
Activity points
1,769
Hi all
i had the following matlab code and it is work well , but the problem is with sampling frequency of the plot of the third plot , it should be an AM modulated signal but it doesn't look like that .
can anyone help with this please ?
the code is
%Amplitude Modulation of laser 193THz
N = 1150; %N point FFT N>fc to avoid freq domain aliasing
fs =1023 ; % sample frequency
t = (0:N-1)/fs;
M = 200; % M point FFT N>fc to avoid freq domain aliasing
fsi = 180;
ti = (0:M-1)/fsi ;
K = 1150; % K point FFT N>fc to avoid freq domain aliasing
fsk = 1023 ;
tk = (0:K-1)/fsk ;
Fc=193*10^12;
Fm=7*10^9;
Vc=5*sin(2*pi*Fc*t);
Vm=5*sin(2*pi*Fm*ti);

V=5*sin(2*pi*Fc*t)+(5/2)*cos(2*pi*(Fc-Fm)*t)-(5/2)*cos(2*pi*(Fc+Fm)*t);

figure('Name','Carrier & Message');
subplot(2,1,1); %Carrier plot
plot(t(1:N/2),Vc(1:N/2));
title('Carrier(Laser)');
xlabel('Time'); ylabel('Vc');
subplot(2,1,2); %message plot
plot(ti(1:M/2),Vm(1:M/2),'r');
title('Message signal');
xlabel('Time'); ylabel('Magnitude');


figure('Name','direct modulation of laser using AM mod.');
subplot(2,1,1); %Time domain plot
plot(tk(1:K/2),V(1:K/2));
title('AM Modulated Signal');
xlabel('Time'); ylabel('AM');

the problem is with the following :

figure('Name','direct modulation of laser using AM mod.');
subplot(2,1,1); %Time domain plot
plot(tk(1:K/2),V(1:K/2));
title('AM Modulated Signal');
xlabel('Time'); ylabel('AM');

the signal should be AM modulated signal but it don't

help me please
 

Hi hitman,

In order to avoid aliasing, Fc+Fm shoul be less than fs/2. That is very far to be true. Aren't you missing something?
If Fc is 193 THz, you shoul not write Fc=193*10^12, but Fc=193e12. Do you understand the difference?

Regards

Z
 

Hi Zoro
do you mean if i write Fc=193*10^12 that will equal to (10*193)^12 ?
or what ?
please help me
 

do you mean if i write Fc=193*10^12 that will equal to (10*193)^12 ?

No. I mean that if you write 193*10^12 you instruct the interpreter to perform a power operation (10 elevated to power 12) and a multiplication (times 193).
Instead, 193e12 is the normal way to specify a constant.
The result should be is pactically the same in this case, but the second is the clean way. There can be numerical (roundoff) errors in the arithmetical operations.
Regards

Z
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top