fs=6e6;
t=0:1/fs:0.5;
s=2*cos(2*pi*1e6*t)+cos(2*pi*2e6*t)+3*cos(2*pi*2.5e6*t);
%%Time Domain
plot(t,s)
xlabel('Time in seconds')
ylabel('Amplitude')
title('Time Domain representation of signal')
xlim([0 0.00001])
%%Frequency Domain
nfft=1024; %%Number of fft points taken
S = abs(fftshift(fft(s,nfft)));
plotindex = (-nfft/2:nfft/2-1)*fs/nfft;
figure
plot(plotindex, S);
title('Frequency Domain Representation of Baseband Signal');
xlabel('Frequency (Hertz)');
ylabel('Magnitude (Absolute Value)');
%%Shifted signal
fs1=49.5e6;
t1=0:1/fs1:0.5;
s1=s.*cos(2*pi*20e6*t1);
%%Time Domain
figure
plot(t1,s1)
xlabel('Time in seconds')
ylabel('Amplitude')
title('Time Domain representation of Shifted signal')
xlim([0 0.00001])
%%Frequency Domain
S1 = abs(fftshift(fft(s1,nfft)));
plotindex = (-nfft/2:nfft/2-1)*fs1/nfft;
figure
plot(plotindex, S1);
title('Frequency Domain Representation of Bandpass Signal');
xlabel('Frequency (Hertz)');
ylabel('Magnitude (Absolute Value)');
I have posted the code above and the problem which has been bugging me is really silly. The matrix dimensions don't agree and so I can't translate my signal. Actually I want to move the sum of cosines from baseband to passband and at baseband the nyquist frequency is 6 MHz and once I translate it, it becomes 49.5 MHz because then the highest frequency component is 22.5 MHz. So I want someone to tell me how I can get the correct results? I know what the problem is which is occurring because of different sample rates but I just want someone to tell me how to make it right. Thanks