find non zero elements in array
Mostra commenti meno recenti
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


Risposte (1)
Soniya Jain
il 10 Lug 2021
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 Commenti
Le Dyk Zuy
il 10 Lug 2021
Soniya Jain
il 11 Lug 2021
So have you tried to select the 'Variable Size' checkbox by specifying the upper bounds in the Size box?
Le Dyk Zuy
il 12 Lug 2021
Categorie
Scopri di più su Code Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!