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일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

질문:

2020년 6월 18일

댓글:

2020년 6월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by