Why my program always get '0' at initialization?

function out=gett(A)
if A(1)==0
out=1;
else
out=0;
end
A(1)
end
My M-file Integrator block :initial condition=-2
Why my program always get '0' at initialization?
but workspace is correct output.
How should I avoid this case?
%

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 26일
편집: Azzi Abdelmalek 2013년 1월 26일

0 개 추천

Your Matlab function is not an integrator, your output signal is 0 or 1
if A(1)==0
out=1;
else
out=0;
end
And the matlab function does not have an initial output setting

댓글 수: 3

YEH
YEH 2013년 1월 26일
oh~I upload the wrong picture...sorry
What does the mean of 'initial output setting'?
Command windows is the 'matlab function' input, and the workspace is the 'matlab function' output, doesn't it?
You are displaying the output of the matlab function. According to your code it is 0 or 1
YEH
YEH 2013년 1월 27일
When time is [0;2;4;6] the input is [-2;0;2;4], so the answer will be [0;1;0;0], that is correct.
But the program get the '0' input that is wrong!! Because the initial input is '-2'.
'0' is the simulink at initialization, I don't want it that is my problem.

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

카테고리

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

제품

질문:

YEH
2013년 1월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by