Embedded program not working for some values of simulation time steps from digital clock..?
조회 수: 2 (최근 30일)
이전 댓글 표시
A digital clock connected to embedded program and its output connected to display.
sample time of digital clock 0.1 sec.
The embedded prog is
function u =check(T)
persistent g j
if isempty(g)
g=0.3
end
if isempty(j)
j=0
end
T %to display the values from digital clock in command window
if T==g
g %to display the value
j=123
end
u=j
g can be intialised with any values 0.1,0.2.....1
When T takes 0.3 it should execute j=123.. but its not doing so, similarly when g is initialsed with 0.3 or 0.6 or 0.7 its not working..but working well with 0.4, 0.5,0.9..
the simulation time kept is 1 sec
댓글 수: 0
답변 (1개)
Azzi Abdelmalek
2013년 1월 20일
편집: Azzi Abdelmalek
2013년 1월 20일
Maybe, there is a problem with the precision. Try to use a tolerence
tol=10^(-6);
if abs(T-q)<tol
댓글 수: 13
Azzi Abdelmalek
2013년 1월 20일
편집: Azzi Abdelmalek
2013년 1월 20일
If you are working with discrete system, in solver option, change the type from variable step to fixed step and set it to the lowest value of your blocks sample time, for example 0.001.(by default it's auto)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!