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

조회 수: 2 (최근 30일)
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
Arnab De
Arnab De 2013년 2월 12일
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by