equation for the sum of sinusoids
Show older comments
Hello,
I am attempting to create a sum of sines waveform using 4 different frequencies, with the same amplitude of 1, and all with a phase of 0. Sampling rate of 60 with a duration of 30 seconds. Through reading different forums I came up with the code below, however I'm not sure I understand the pi/3, pi/4, etc. used in the x1-x4 equations below. Can anyone explain why this is included? or if there is a better more simple formula than what I have below.
Fs = 60;
Ts = 1/60;
t = 0:Ts:30
x1 = 1*cos(2*pi*.73*t+pi/3);
x2 = 1*cos(2*pi*1.33*t-pi/4);
x3 = 1*cos(2*pi*1.93*t+pi/5);
x4 = 1*cos(2*pi*2.93*t-pi/6);
x = x1 + x2 + x3 + x4;
u = numel(x);
M = zeros(u,6);
M(:,3) = x;
M(:,(1:6)~=3);
M
figure(2)
subplot(5,1,1)
h = plot(t,x1); box off; grid off
xlabel('Time(s)');
ylabel('Amplitude');
subplot(5,1,2)
h = plot(t,x2); box off; grid off
xlabel('Time(s)');
ylabel('Amplitude');
subplot(5,1,3)
h = plot(t,x3); box off; grid off
xlabel('Time(s)');
ylabel('Amplitude');
subplot(5,1,4)
h = plot(t,x4); box off; grid off
xlabel('Time(s)');
ylabel('Amplitude');
subplot(5,1,5)
h = plot(t,x); box off; grid off
xlabel('Time(s)');
ylabel('Amplitude');
Accepted Answer
More Answers (0)
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!