matlab-coder

Constants and Matlab Coder

橙三吉。 提交于 2019-12-12 11:26:41
问题 Some functions requires the input to be a constant, when run in Matlab Coder. I wish to find a way to declare the input as a constant before it is input as an example for the problematic situation: function foo = subsubfunction(x,y) [B,A]=butter(1,x/y); This will return the error 'All inputs must be constant' How do I declare x and y as constants so that butter() gets happy? I have tried many solutions and unfortunately not found anything really satisfying. If the command line operation coder

Python ctypes definition for c struct

Deadly 提交于 2019-12-12 10:36:07
问题 I am trying to call some c code generated by the Matlab coder. Matlab uses a c struct called emxArray to represent matrices (documented here: http://www.mathworks.co.uk/help/fixedpoint/ug/c-code-interface-for-unbounded-arrays-and-structure-fields.html). struct emxArray_real_T { double *data; int *size; int allocatedSize; int numDimensions; boolean_T canFreeData; }; I have little experience ctypes and am struggling to create an equivalent struct that I can then use to pass vectors back and

Converting a C char array into a Matlab String using Matlab Coder

天大地大妈咪最大 提交于 2019-12-12 03:48:47
问题 I have some code written in Matlab that I am converting into C code using Matlab Coder. I have written a C function that I want to call from the generated C code. This works, so far so good. The problem is that one of the parameters to the C function is a char** used to output a string. I accomplish this by making an opaque char* and using coder.wref to get the char**. But how do I convert the opaque char* to a Matlab string so I can return it from my function? The code goes something like

Matlab C++ - Receive Dynamic Size Output type (emxArray_real_T)

本小妞迷上赌 提交于 2019-12-11 11:57:41
问题 I have converted some matlab code to C++ using coder. void myfunction(const emxArray_real_T *input, emxArray_real_T *output){ ... } I have setup to send emxArray_real_T type inputs without any issues. How do I setup to receive dynamic sized output in C++ which is calling myfunction ? Code updated: main(){ . . . double *inputVec; inputVec=(double*)malloc(1000 * sizeof(double)); emxArray_real_T *input; emxArray_real_T *output; input=emxCreateWrapper_real_T(&inputVec[0],1,1000); output =

Basic networking with Matlab Coder

谁说胖子不能爱 提交于 2019-12-08 12:50:36
问题 I'm trying to get very basic network functionality with Matlab Coder (I need to turn it into C code). However, all the network classes and objects I try arn't supported by Coder. It seems unreasonable that Matlab would completely neglect networking entirely with this tool. Is there some method of sending data over a network that DOES work with coder? I'd prefer TCP, but UDP or anything else that will actually send/receive data will work, as long as it is compatible with Coder. 回答1: This

How to convert float[][] type array to “emxArray_real_T *x”

徘徊边缘 提交于 2019-12-08 02:41:21
问题 I have converted a function which takes a NxN matrix as input and gives a NxN matrix output from matlab to C, using the MatlabCoder. It gave me the function which has two parameters namely void func(const emxArray_real_T *x, emxArray_real_T *y) I get that x is the input to the function and i can get the output of the function from y. The problem is i have a array in float[][] and i wish to give this data as an input to the func, which only takes emxArray_real_T *x as an input. Any ideas on

Matlab Codgen eig() function - strange behaviour

孤街浪徒 提交于 2019-12-07 23:15:50
问题 First, don't be fooled by the long post, there is not a lot of code just an observation of results so there are few example matrices. This is a bit related to this question: Matlab Codegen Eig Function - Is this a Bug? I know that mex/C/C++ translated eig() function may not return the same eigenvectors when using the same function in MATLAB and that's fine, but i am puzzled with results I'm getting. First this simple example: Output % c = diagonal matrix of eigenvalues % b = matrix whose

switch-case with multiple matches in matlab for code generation

霸气de小男生 提交于 2019-12-07 17:20:37
问题 The following code is valid matlab sytax to check whether b matches any elements in a . However, if the code is used for code generation (i.e. simulink) then I get the error: 'code generation only supports cell operations for varargin and varargout You can check this by adding %#codegen at the top of the script.) a={2 3}; b=3; switch b case a disp yay otherwise disp boo end What should I do to match multiple patterns in a case statement in code-generation compatible code? The following don't

When does Matlab choose to thread when using codegen and parfor

末鹿安然 提交于 2019-12-06 12:14:54
问题 I seem to be one of few people using the Matlab coder (codegen command) to get speedup, judging by the fact that there is so little discussion or help on-line. I've gotten incredible speedups from it in some cases. I've never seen it documented, but when I make a MEX file using codegen from a Matlab script with a parfor loop, it often will thread the resulting MEX. Parfor in functions spawns multiple processes which is often less efficient than just threading (I'm inferring all this from

Matlab Codgen eig() function - strange behaviour

烂漫一生 提交于 2019-12-06 11:44:32
First, don't be fooled by the long post, there is not a lot of code just an observation of results so there are few example matrices. This is a bit related to this question: Matlab Codegen Eig Function - Is this a Bug? I know that mex/C/C++ translated eig() function may not return the same eigenvectors when using the same function in MATLAB and that's fine, but i am puzzled with results I'm getting. First this simple example: Output % c = diagonal matrix of eigenvalues % b = matrix whose columns are the corresponding right eigenvectors function [ b, c ] = eig_test(a) [b, c] = eig(a); end