find non zero elements in array
15 ビュー (過去 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/679513/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/679518/image.png)
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!