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.

matlab help on frequency spectrum plot

Status
Not open for further replies.

abhinaykundur

Newbie level 1
Joined
Dec 15, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
hi i'm writing a code for modulating a triangle wave with a sine carrier and plot its frequency spectrum. i should get my spectrum at +fc and -fc but i got them at +2fc and -2fc. my code is

clc;close all;
%td=input('enter a time delay:');
%k=ceil(1/td);
%n=1;
T=0.1;
%p=ceil(k*T);
%disp(p);
%I = zeros(p,1);
%I(1)=0;
%beta=4;
%disp(k);
alpha0=3.5;
f=100e3;
fc = 1e6;
%t=linspace(0,T,p);
p=3.*(fc+2.*f);
disp(p);
t=linspace(0,T,p);
alpha_dc=alpha0*rectpuls(t-0.05,0.1);
plot(t,alpha_dc);
ylim([0 5]);
%plot(t,alpha_dc);
%xlabel('alpha');
%ylabel('amplitude');
%x = 0:0.0000005:2*pi;
alpha_ac=0.25*sawtooth((2*pi*f*t),0.5);
figure;plot(t,alpha_ac);xlabel('\t'); ylabel('x2(t)');
%grid
%xlim([0 1e-5]);
%alpha = zeros(p,1);
alpha=alpha_dc+alpha_ac;
figure;plot(t,alpha);
xlim([0 1e-5]);
%axis([0 1e-5 -1 1]);
C = cos(2*pi*fc*t);
M = C.*alpha;
I = C+M;
%subplot(1,2,1);
%figure;
%plot(alpha(1,:),I);
%xlabel('alpha');
%ylabel('intensity');
figure;
plot(t,I);
xlim([0 0.05/100]);
%J=zeros(p,1);
%N=length(I);
int=t(2)-t(1);
disp(int);
%X=abs(fft(I,20*N));
%X=(fftshift(X));
X=zeros(p,1);
X = fftshift(abs(fft(I,5*length(I))));
w = linspace(-1/int,1/int,length(X));
%f=(-(N-1)/2:(N-1)/2);
%win=hamming(2048);
%J=win.*X(1:length(win));
figure, plot(w,X);
xlim([-5e6 5e6]);
also my amplitude in the frequency spectrum shoots up even when all my amplitudes are less than 4 V. please help me thank you
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top