Borrar filtros
Borrar filtros

Defining function arguments using Assert function for code conversion to C++

2 visualizaciones (últimos 30 días)
What is the proper syntax for using the assert command to define the function arguments in my Matlab function below from which I want to generate C++ code using Matlab Coder? Below I give the beginning of such a code and as far as I know how to do successfully.
An example of my desired structure would be:(This section is not part of the code)
acme_employees.employeeID = [1 2]
acme_employees.name(1) = 'Bob'
acme_employees.name(2) = 'Renee'
acme_employees.resume_path(1) = 'c:\resumes\bob.doc'
acme_employess.resume_path(2) = 'c:\resumes\renee.doc'
Note! - The code begins here
function numEmployees = numEmployees_count(acme_employees)
%#codegen
assert(isstruct(acme_employees));
assert(isa(acme_employees.employeeID,'double'));
assert(all(size(acme_employees.employeeID) == [inf 1]));
  1 comentario
Arnab De
Arnab De el 12 de Feb. de 2013
This code works for me. It generates a structure with a single field named employeeID which is a variable-sized, dynamically allocated array of doubles. Is this what you want? Of course, you need to add asserts for other fields. Are you getting any error from codegen? If yes, which version of MATLAB are you using?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by