Some of my variables are not initialized when converted to C using Coder
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to learn Matlab Coder using the tutorials and example files.
When I convert the following .m code into C++ code using Matlab Coder the block of code addressing x_est and p_est is ignored as seen in the generated C++ code that follows. I have looked through all of the other accompying files created by Coder and it is not addressed in any of them either. Is there a reason for this?
** Matlab .m code:
% Copyright 2010 The MathWorks, Inc.
function y = Temp(z)
%#codegen
persistent x_est p_est % Initial state conditions
if isempty(x_est)
x_est = zeros(6, 1); % x_est=[x,y,Vx,Vy,Ax,Ay]'
p_est = zeros(6, 6);
end
% Pre-allocate output signal:
y=zeros(size(z));
end % of the function
** Matlab Coder C++ generated code:
/*
* Temp.c
*
* Code generation for function 'Temp'
*
* C source code generated on: Tue Dec 04 15:45:49 2012
*
*/
/* Include files */
#include "rt_nonfinite.h"
#include "Temp.h"
/*
* function y = Temp(z)
*/
void Temp(const real_T z[10], real_T y[10])
{
memset(&y[0], 0, 10U * sizeof(real_T));
/* of the function */
}
/* End of code generation (Temp.c) */
0 commentaires
Réponse acceptée
Arnab De
le 5 Déc 2012
The variables x_est and p_est are not used in the MATLAB code. Therefore the compiler eliminates them.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Coder dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!