-1
\$\begingroup\$

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 enter image description here 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.


\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Karlsen Oct 25 '18 at 12:45
  • \$\begingroup\$ @PeterKarlsen Yes you are right. I tried it and it worked. Why don't you post it as answer? \$\endgroup\$ – Hazem Oct 25 '18 at 12:49
0
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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 \$\endgroup\$ – David Oct 25 '18 at 13:01
  • \$\begingroup\$ @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. \$\endgroup\$ – sstobbe Oct 25 '18 at 13:53
  • \$\begingroup\$ 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. \$\endgroup\$ – David Oct 26 '18 at 4:24
  • \$\begingroup\$ 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. \$\endgroup\$ – Peter Karlsen Oct 26 '18 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.