Square wave
3 次查看(过去 30 天)
显示 更早的评论
Hello I'm having a problem creating a square wave where i can change the pulse width and amplitude as need. Can anyone help point me in the right direction?
0 个评论
采纳的回答
Walter Roberson
2011-11-12
RESOLUTION = 1000; %whatever is appropriate
DUTYCYCLE = 0.73; %e.g. 73% on, 27% off
NUMBEROFCYCLES = 18; %as appropriate
basepulse = ones(1,RESOLUTION);
squarepulse = basepulse;
squarepulse(floor(DUTYCYCLE * RESOLUTION) + 1 : end) = 0;
wavetrain = repmat(squarepulse, 1, NUMBEROFCYCLES);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!