defining output as unbound (1x:inf) vector for coder.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Im having trubble defining a vector to be unbound when i use the Coder to generate C code. I wish to have a vector of type double 1x:inf, that will later generate a pointer to a struct containing the unbound vector when using Coder.
function [V2SAgent,bMove,s_Result] = V2SOnPublishedPrice(V2SAgent, oPPdata, ePochNow)
%#codegen
bMove = false;
s_Result = struct('d_BidMove', zeros(1,0),'d_AskMove', zeros(1,0),'i_VolBands', zeros(1,0));
coder.varsize('s_Result(:).d_BidMove',[1,inf],[false,true]));
coder.varsize('s_Result(:).d_AskMove',[1,inf],[false,true]));
coder.varsize('s_Result(:).i_VolBands',[1,inf],[false,true]));
coder.cstructname(s_Result, 'Move_t');
.....DOES ALOT OF WORK .....
When i process the function with the coder i end up with a struct looking like this.
struct emxArray_real_T_1x0
{
int size[2];
};
typedef struct {
emxArray_real_T_1x0 d_BidMove;
emxArray_real_T_1x0 d_AskMove;
emxArray_real_T_1x0 i_VolBands;
} Move_T;
The type emxArray_real_T_1x0 is by no means unbound. In other senarios i managed to achive the output im looking for using the Input, that i can define to be of time 1x:inf using the Coder, and using this to set the output variable in my function.
function s_Result = V2SOnPublishedPrice(infVector)
%#codegen
s_Result = struct('d_BidMove', zeros(1,0))
coder.varsize('s_Result(:).d_BidMove');
coder.varsize(d_BidMove);
coder.cstructname(s_Result, 'Move_t');
....SOME WORK....
s_Result.d_BidMove = infVector;
end
When put though to coder where infVector is defined as 1x:inf i get a output like this.
struct emxArray_real_T
{
double *data;
int *size;
int allocatedSize;
int numDimensions;
boolean_T canFreeData;
};
typedef struct {
emxArray_real_T *d_BidMove;
emxArray_real_T *d_AskMove;
emxArray_real_T *i_VolBands;
} Move_T;
For the senario i used to define and test my functions this is fine, but i know i cant cover all the possible inputs i can get, so i need a output that is unbound so i have a uniform input/output across my functions, and i dont risk getting size missmatch or out of range errors.
0 commentaires
Réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!