필터 지우기
필터 지우기

What is the args for codegen for a double?

조회 수: 6 (최근 30일)
GARRETT CHAN
GARRETT CHAN 2017년 7월 24일
댓글: Ricardo Gutierrez 2020년 12월 7일
This is my function ... function funcX(voltage_0,voltage_1,current,voltge_setting)
How do I create the codegen command-line ? Those are function inputs are all double data types.

답변 (1개)

Andy
Andy 2017년 7월 24일
Hi Garrett,
To compile a function that takes arguments simply use "codegen fcnName -args" followed by a cell array of example input values.
So, assuming that you want to compile funcX and "voltage_0","voltage_1","current", and "voltge_setting" are all meant to be scalar doubles you could run the following from command line:
codegen funcX -args {1,2,3,4}
More information on the codegen command is provided at: https://www.mathworks.com/help/coder/ref/codegen.html
  댓글 수: 3
Ryan Livingston
Ryan Livingston 2020년 11월 28일
If you want the array to be the same size as V and have V assigned in your workspace, just do:
codegen funcX -args V
You can use coder.typeof to make the argument variable-sized
codegen funcX -args coder.typeof(V, [100, Inf], [1, 1])
To pass a :100 x :? variable-sized array.
Ricardo Gutierrez
Ricardo Gutierrez 2020년 12월 7일
Dear Ryan,
Thank you. I have another question, if I have several entries (scalars and arrays), can you tell me what the syntax with variable length of arrays would be like ?. Another thing, can the "varargin" variable be used as well?

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

카테고리

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