Eliminate zero and negative roots by Embedded Matlab Function

조회 수: 1 (최근 30일)
Amro
Amro 2014년 5월 24일
답변: Amro 2014년 5월 28일
Hello,
I have used an embedded matlab function in simulink to Eliminate zero and negative roots in the input vector(u) so the output(y) will be vary in size according to that. The following is the code that I have written in this block:
function y = clipo(u) u(u <= 0) = []; coder.varsize('y',4); y=u;
But I get the error: Dimension 2 is fixed on the left-hand side but varies on the right ([1 x 4] ~= [1 x :?]).
Thanks ahead....

답변 (2개)

Mike Hosea
Mike Hosea 2014년 5월 24일
The input u is fixed-size, so it is impossible to delete elements from it. Instead, copy it to a variable-size array and then delete elements from there.
function y = clipo(u)
coder.varsize('y');
y = u;
y(y<=0) = [];

Amro
Amro 2014년 5월 28일
Thanks....

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by