필터 지우기
필터 지우기

why is output of my MATLAB function in Simulink raises with slope?

조회 수: 2 (최근 30일)
Berkin Birol
Berkin Birol 2018년 11월 16일
댓글: Berkin Birol 2018년 11월 21일
Hello everyone,
I tried to implement my own pulse generator with variable inputs. When I simulate it and compare results with the build in Pulse Generator I see that my output becomes high with a slope, but Simulink's Pulse Generator becomes high immediately. How can I have this kind of output?
Simulation performed for 100 seconds, with Fixed-step, discrete solver and Fixed-step size has been taken "1".
function [y, countTime] = fcn(Amplitude, period, width, phaseDelay, timeIncremental, Clock, pre_y, preCountTime)
%Setting previous values.
y=pre_y;
countTime=preCountTime;
%y is high for 'width' time, so it can be low again
if countTime==width
y=0;
end
%Counting the time between two high values
if y>0 || countTime>0
countTime=countTime+timeIncremental;
end
%Output is high first time after 'phase delay' passes.
if Clock==phaseDelay
y=Amplitude;
end
%Period has been reached, y is high again.
if countTime==period
countTime=0;
y=Amplitude;
end
pulseGeneratorOutput.png
  댓글 수: 3
Berkin Birol
Berkin Birol 2018년 11월 16일
Thank you for your reply. The solver was fixed step and in the same solver Simulink's own pulse generator works just fine. I think I miss something due to my lack of experience in Simulink.
Berkin Birol
Berkin Birol 2018년 11월 21일
I solved the issue with zero order hold block and uploaded the block to: https://www.mathworks.com/matlabcentral/fileexchange/69483-customizable-pulse-generator.
But, I am still wondering if there is an another way(without ZOH) to do this.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by