Program Code
% PWM Signal Generationclc;
close all;
clear all;
t=0:0.001:1;
s=sawtooth(2*pi*10*t+pi);
m=0.75*sin(2*pi*1*t);
n=length(s);
for i=1:n
if (m(i)>=s(i))
pwm(i)=1;
elseif (m(i)<=s(i))
pwm(i)=0;
end
end
plot(t,pwm,'-g',t,m,'--r',t,s,'--b');
grid on;
ylabel('Amplitude');
xlabel('Time index');
title('PWM Wave');
axis([0 1 -1.5 1.5]);
Output
_________________
getting an error called Undefined function or variable
ReplyDelete'l'.
please help
i am new to matlab
Respected sir
DeleteVariable 'l' is not used in this program. You might have mistaken 1(one) or i as 'l'.
hello sir,
ReplyDeleteme generate the PWM form the micro controller pin and me used MPLAB IDE v8.88 with Hi-Tech compiler............ then please send me some code for this project.
Respected madam,
DeleteMay your project be a success. Wish you all success in your project.
Respected visitors of this blog,
ReplyDeleteIt would be nice if any of you send Ms. Pooja Mehta some code for her project as soon as possible or posted the code for the project here as a comment so that she can view it
i am getting an error pwm not defined ?? what to do plz help
ReplyDeleteRespected Sir,
DeleteThank you very much for spending your precious time to visit this humble weblog.
When I ran the program code I published in this page, I got output. The output I got is also given in this page under the caption 'Output'. So you please copy the entire program given here using the copy option and paste it to your computer using paste option. After that you please save and run the program in MATLAB.
Please don't give the file name as pwm.
After that kindly inform us about the output by posting a comment here. If you still face any problem in getting the correct output, then please inform us. We are always at your service.
Thank you for being kind enough to visit this weblog. Thank you for asking me this question and thus giving me a chance to serve a honourable person like you.I am greatly obliged you for this. Wish you good health, success and happiness. May your friends and relatives also have good health, success and happiness.
Waiting for you reply