Ads Below The Title

Sine Wave to Square Wave conversion using MATLAB


%60Hz sine wave to 20Hz square wave conversion
clear all;
close all;
clc;
fm=input('enter msg frequency fm=');
fr=input('enter mult frequency fr=');
fs=2000;
t=0:1/fs:0.2;
x=5*sin(2*pi*fm*t);
f=(fm-fr);
y=5*sin(2*pi*t*f);
for i=1:401
if(y(i)>=0)
    s(i)=+5
else
    s(i)=-5
end
end

subplot(311);
plot(x,'-','linewidth',1);

title('60Hz sine wave','fontsize',12);
xlabel('--->time in 0.5ms');
ylabel('--->Volts');
subplot(312);
plot(y,'g','linewidth',1.5);

title('20Hz sine wave','fontsize',12);
xlabel('--->time in 0.5ms');
ylabel('--->Volts');
subplot(313);
plot(s,'r','linewidth',1.5);

title('20Hz square wave','fontsize',12);
xlabel('--->time in 0.5ms');
ylabel('--->Volts');




RESULT:
Sine Wave to Square Wave conversion using MATLAB Sine Wave to Square Wave conversion using MATLAB Reviewed by haru on April 03, 2013 Rating: 5

No comments

Ads Inter Below The Post
Image Link [https://lh3.googleusercontent.com/-wlvSkBWGUW0/AAAAAAAAAAI/AAAAAAAAAxU/6FpWSjn-h2o/s120-c/photo.jpg] Author Name [Sora Templates] Author Description [Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard] Facebook Username [#] Twitter Username [#] GPlus Username [#] Pinterest Username [#] Instagram Username [#]