find non zero elements in array
조회 수: 13 (최근 30일)
이전 댓글 표시
im trying to implement find non zero elements without using "find' toolbox in simulink. im using matlab function block as shown on the screenshot
function y = non_zero(u)
x=find(u);
y=x
댓글 수: 0
답변 (1개)
Soniya Jain
2021년 7월 10일
As mentioned in the error, that y is non-tunable, so have you tried to select the 'Variable Size' checkbox by specifying the upper bounds in the Size box?
Also, find function will return the index of the non zero elements in a vector, so if you want values at the index, you can code in the following way:
function y = non_zero(u)
x = find(u); % will return index of non-zero elements
y = y(x);
end
댓글 수: 3
Soniya Jain
2021년 7월 11일
So have you tried to select the 'Variable Size' checkbox by specifying the upper bounds in the Size box?
참고 항목
카테고리
Help Center 및 File Exchange에서 HDL Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!