output a matrix from embedded matlab function block

2 vues (au cours des 30 derniers jours)
Pinkymol
Pinkymol le 21 Nov 2013
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

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by