output a matrix from embedded matlab function block

조회 수: 2 (최근 30일)
Pinkymol
Pinkymol 2013년 11월 21일
Inside a simulink model, I want to transform a vector V=[g,h]' to V1=[k k-g k-g-h]' where k varies from 0 to 2. and out of the three possible vectors of V1 ( for k=0,1,2) I should select only those vectors that contain all non-negative elements. for this I have used embedded matlab function block and wrote the program as given below but gives error (Data 'u' (#124) is inferred as a variable size matrix, while its specified type is something else.)
please help..
function u = fcn(g,h)
%#codegen
v=[0 0-g 0-g-h;1 1-g 1-g-h;2 2-g 2-g-h]';
% this will create a matrix where the colum represents the 3 possible vectors for k=0 to 2.
t= any((v)<0);% this check the columns of 'v'
u=v(:,~t); %'u' is the new required matrix where the column gives the required vectors .
end

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by