Answer to Question #211906 in MatLAB for Rama

Question #211906

Write a MATLAB code to calculate and plot the following problem.

Rectifier: Find the Fourier series of the function obtained by passing the

voltage v(t) = 10 sin(100xt)through a half-wave rectifier that clips the negative

half-waves.



1
Expert's answer
2021-06-30T03:14:44-0400
close all,
clear all,
clc,


Fs=1000;
t = 0:(1/Fs):1;
Amp = 10;
F = 100/(2*pi);
Vin = Amp*sin(100*t);
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
subplot(2,2,1);
plot(t,Vin);
grid on,
xlabel('--- t --->');
ylabel('--- Vin --->');
ylim([-Amp*0.9 Amp*1.1]);
str = strcat('Input Voltage Waveform at Freq. = ',32,num2str(uint8(F)),32,'Hz and Fs = ',32,num2str(Fs),32,'Hz');
title(str,'FontSize',14);
Vout=Vin;
for r=1:length(Vin)
    if(Vout(r)<0), Vout(r)=0; end
end
subplot(2,2,3);
plot(t,Vout);
grid on,
xlabel('--- t --->');
ylabel('--- Vin --->');
ylim([-Amp*0.9 Amp*1.1]);
str = strcat('Half Wave Rectifier Output with -ve Clippings');
title(str,'FontSize',14);


L=length(Vout);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(Vout,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);
% Plot single-sided amplitude spectrum.
subplot(2,2,[2 4]); plot(f,2*abs(Y(1:NFFT/2))); 
str = strcat(num2str(NFFT),32,'points FFT of Vout'); 
title(str,'FontSize',14); grid on




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS