Hello my name is Fattah, i am new in Matlab.
Can anybody here do me a favor? I want to plot a PWM Signal that have frequency = 490 Hz, Amplitude = 0 - 5, and Duty Cycle 50%. I've already try this : https://www.mathworks.com/help/signal/ref/square.html, but i have no idea how to set the frequency and the amplitude.
Thank you.

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-6-18
编辑:Ameer Hamza 2020-6-18
Try this
f = 490;
A = 5;
t = linspace(0, 0.01, 10000);
y = A*square(2*pi*f*t);
plot(t, y)
xlabel('time');
ylabel('Amplitude');

4 个评论

Thank you Ameer. I have a question. How to change the amplitude range value between 0 and 5?
Change the line to
y = A*(square(2*pi*f*t)+1)/2;
It works. Thank you Ameer
I am glad to be of help!!!

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by