# Plot of a mixed signal in matlab

I have the following signal

xa=4000.*sin(2*pi*f1*t)+1000.*sin(2*pi*f2*t)+ 500.*sin(2*pi*f3*t);


and the values of f1,f2 and f3 are

f1=50000;
f2=500000;
f3=2500000;


and with the above information I have to find a figure like in MATLAB. I am using the following code but not getting a figure like this.

close all;
clc;
%subplot(2,1,1)
t=0:0.0005:1;
f1=50000;
f2=500000;
f3=2500000;
xa=4000.*sin(2*pi*f1*t)+1000.*sin(2*pi*f2*t)+ 500.*sin(2*pi*f3*t);
% xa=cos(2*pi*f*t);
plot(t,xa)


I also tried with the different time intervals t but not getting the required figure.

• What does your plot look like? I think your t interval is WAY off. The time span in the plot is 100us. Try with t=0:0.00000005:0.0001 or something like that. – Peter Karlsen Oct 25 '18 at 12:45
• @PeterKarlsen Yes you are right. I tried it and it worked. Why don't you post it as answer? – Hazem Oct 25 '18 at 12:49

## 1 Answer

What does your plot look like? I think your t interval is WAY off. The time span in the plot is 100us. Try with t=0:0.00000005:0.0001 or something like that

• thank you, it worked, but how did you find the range of t like t=0:0.00000005:0.0001, can you tell me the calculation behind it – David Oct 25 '18 at 13:01
• @TuhinDas Your sample rate was WAY below the Nyquist frequency of any of the sinusoids and your time span was 50000 cycles of f1 versus 5 as Peter suggests. – sstobbe Oct 25 '18 at 13:53
• t=0:0.00000005:0.0001, how come Nyquist interval become 0.00000005, because according to the formulation Nyquist interval is T=1/2fm, fm is the maximum frequency of the message signal T=1/2*2500000=0.0000002. – David Oct 26 '18 at 4:24
• You are right about the Nyquist interval. 0.00000005 was just a number that would give you enough samples to see the plot. No calculation behind it, just a rough estimate. – Peter Karlsen Oct 26 '18 at 7:51