필터 지우기
필터 지우기

strfind in stateflow

조회 수: 2 (최근 30일)
Luhur
Luhur 2011년 7월 17일
hi all
i have code in my embedded matlab function:
function V=sequence(x,n)
%#codegen
correct= testinput(x,n);
if correct
V=10;
else
V=1;
end
function correct = testinput(x,n)
eml.extrinsic('strfind');
correct = any(strfind((x')>4 & (x')<7,ones(1,n)));
how do we wrote it on stateflow??? could anyone send me the screenshoot of the stateflow block and Embedded matlab function inside of it???
thanks

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 7월 17일
Type "sf_seqrec" to open the demo model. Or search for "Sequence Recognition Using Mealy and Moore Charts" in doc. You just need to understand the basics of Stateflow chart such state and transition. In your case, one state is enough to do the job. You can also find other Stateflow tutorial to get started.
  댓글 수: 2
Luhur
Luhur 2011년 7월 17일
i already knew stateflow fang, but how to use strfind in stateflow is not common for me.. ok, i will check the demo...
thanks fang, for now...
Fangjun Jiang
Fangjun Jiang 2011년 7월 18일
No. You don't use strfind() function. You use Stateflow. Define a state called "Counting" and an internal variable called "count", any time the input value is between 4 and 7, you enter or stay in the "Counting" state and an "count" is increased by 1. Any time the next input is not between 4 and 7, you get out of state "Counting" and "count" is reset to 0. If "count" is greater or equal to n, your output "V" is 10, otherwise, "V" is 1.

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

카테고리

Help CenterFile Exchange에서 Complex Logic에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by