strfind in simulink and stateflow
Show older comments
hi all,,
i have condition using strfind in simulink and embedded matlab function.
here is my EMF:
function V=sequence(x)
correct= @(x)any(strfind((x)>4,[1 1 1 1 1]))
if correct(x)
V=10000;
else
V=1
end
- my input from simulink are:[5 5 5 5 5 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3]
- the output: V=1
- supposed V=10000
why it keeps telling me not the correct answer based on my condition????
what about in stateflow???
thanks
Accepted Answer
More Answers (3)
Kaustubha Govind
on 7 Jul 2011
Do you mean that you expect V=10000, but you actually get V=1? I don't know what you've done differently, but after changing your code to fit Embedded MATLAB restrictions, I got 10000 as output from the Embedded MATLAB Block:
function V=sequence(x)
%#codegen
correct= testinput(x);
if correct
V=10000;
else
V=1;
end
function correct = testinput(x)
coder.extrinsic('strfind');
correct = any(strfind((x)>4,[1 1 1 1 1]));
Paulo Silva
on 7 Jul 2011
if any(strfind((x)>4,[1 1 1 1 1]))
V=10000;
else
V=1
end
5 Comments
Luhur
on 7 Jul 2011
Paulo Silva
on 7 Jul 2011
you have to declare any and strfind extrinsic functions, I didn't test the code
Luhur
on 9 Jul 2011
Luhur
on 9 Jul 2011
Luhur
on 9 Jul 2011
Luhur
on 7 Jul 2011
0 votes
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!