In: Electrical Engineering
Generate and plot sinusoids of frequencies 300 Hz, 500 Hz and 1200 Hz. Plot each of them and their sum using the “subplot” command in one figure. Indicate the axes’ titles.
Sinusoidal signal with frequency 300Hz:
clc;
clear all;
close all;
f=300; %Frequency of signal
T=1/f; %Time period of signal
A=1; %Amplitude of sinusoidal signal
t=linspace(0,0.005,100); % Make 100 samples in the range 0 to 2
times TimePeriod(upto time interval you want).
v1=A*sin(2*pi*f*t); % sinusoidal signal function
plot(t,v1); % to plot the signal voltage amplitude vs time
xlabel('Time(sec)');
ylabel('Voltage(V)');
title('Sine wave-1');
grid on;
Sinusoidal signal with frequency 500Hz:
clc;
clear all;
close all;
f=500; %Frequency of signal
T=1/f; %Time period of signal
A=1; %Amplitude of sinusoidal signal
t=linspace(0,0.005,100); % Make 100 samples in the range 0 to 2
times TimePeriod(upto time interval you want).
v2=A*sin(2*pi*f*t); % sinusoidal signal function
plot(t,v2); % to plot the signal voltage amplitude vs time
xlabel('Time(sec)');
ylabel('Voltage(V)');
title('Sine wave-2');
grid on;
Sinusoidal signal with frequency 1200Hz:
clc;
clear all;
close all;
f=1200; %Frequency of signal
T=1/f; %Time period of signal
A=1; %Amplitude of sinusoidal signal
t=linspace(0,0.005,100); % Make 100 samples in the range 0 to 2
times TimePeriod(upto time interval you want).
v3=A*sin(2*pi*f*t); % sinusoidal signal function
plot(t,v3); % to plot the signal voltage amplitude vs time
xlabel('Time(sec)');
ylabel('Voltage(V)');
title('Sine wave-3');
grid on;
SUBPLOT:
clc;
clear all;
close all;
f1=300; %Frequency of signal
T1=1/f1; %Time period of signal
f2=500; %Frequency of signal
T2=1/f2; %Time period of signal
f3=1200; %Frequency of signal
T3=1/f3; %Time period of signal
A=1; %Amplitude of sinusoidal signal
t=linspace(0,0.02,1000); % Make 100 samples in the range 0 to 2
times TimePeriod(upto time interval you want).
v1=A*sin(2*pi*f1*t); % sinusoidal signal function
v2=A*sin(2*pi*f2*t); % sinusoidal signal function
v3=A*sin(2*pi*f3*t); % sinusoidal signal function
vt=v1+v2+v3;
subplot(4,1,1);plot(t,v1);
ylabel('sinwave_1(300Hz)');
grid on;
subplot(4,1,2);plot(t,v2);
ylabel('sinwave_1(500Hz)');
grid on;
subplot(4,1,3);plot(t,v3);
ylabel('sinwave_1(1200Hz)');
grid on;
subplot(4,1,4);plot(t,vt);
ylabel('sum of three sinusoidal signals');
grid on;
xlabel('Time(sec)');
title('Sinusoidal signal addition');
grid on;