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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by