MATLAB Coder™ generates standalone C and C++ code from MATLAB® code. The generated source code is portable and readable.MATLAB Coder supports a subset of core MATLAB language features, including program control constructs, functions, and matrix operations. It can generate MEX functions that let you ...
8
votes
1answer
116 views
+100
How MATLAB code generation infers output size with nested branches
When generating C code using MATLAB Coder, the behaviour is different when an if happens in body of another if or in its elsesection. The following case easily creates C code with output having size ...
0
votes
0answers
31 views
Different behaviors on Simulink
I am creating a simulink library block. This block can have 3 different behaviors, one very fast (most common case by far) and the two others very slow. I first implemented it using a configurable ...
0
votes
1answer
47 views
Get the data out of the emxArray_real_T
I have converted a simple code to C++ using Matlab coder. However, my main problem is that I cannot get its output! How can I convert the output which is an emxArray_real_T type to a C++ array and ...
0
votes
0answers
63 views
Integrate C function with multiple outputs built with MATLAB Coder
I have been coding in MATLAB and I managed to convert my work to a single function, however it has several inputs and outputs. For the sake of simplicity, lets say it receives three inputs: X ...
0
votes
1answer
73 views
Why Matlab Coder is slow?
I'm trying to build a Mex function in Matlab-r2015a using Matlab Coder. The entry point function I want to convert is alg.m which is called by main.m.
Following the procedure, I'm at the step in ...
1
vote
0answers
50 views
Mex function with OS X 10.9.5 and Xcode 6.2?
I'm using Matlab Coder in Matlab-r2014b in OS X 10.9.5. I have Xcode 6.2. I'm unable to generate a Mex function using Matlab compiler. I'm reporting here a sample code with structure and type of ...
0
votes
2answers
54 views
MATLAB Coder and parfor in MATLAB R2014b
Does the MATLAB Coder in MATLAB R2014b support parfor?
If I check the documentation, it reports:
Treated as a for-loop in a MATLAB Function block.
Does that mean that there is no speed ...
0
votes
0answers
91 views
Hand written word recognition using Matlab
I am working on a hand written word recognition project.
With this project, I have collected sample hand written scripts from several different writers. Hence I have obtained different writing ...
1
vote
1answer
39 views
Matlab Code Generation for Handle Classes Reallocated in a Loop
I am running into some behavior in Matlab Coder that I don't completely understand. To simplify, here's a short example that exhibits the behavior. If I have a handle class defined as:
classdef ...
0
votes
1answer
46 views
Automatic differentiation of Matlab Coder generated C code [closed]
I have a Matlab function which I need to
1) Speed up
2) Generate derivatives of the function by means of Automatic Differentiation (AD).
The speed up part I have accomplished by using Matlab Coder ...
0
votes
2answers
43 views
mex file not executing in MATLAB 7.5.0 (R2007b)
I created a .mex file of a MATLAB file test.m from MATLAB R2012b using MATLAB coder.
I got the output file test_mex.mexa64. I was hoping to use this .mex file in MATLAB 7.5.0 (R2007b) but it shows ...
0
votes
3answers
63 views
Matlab Coder : Matlab Array to C Array
I used matlab coder to convert a matlab code to C. The simple array I had defined in matlab got converted to a complicated struct in C.
struct emxArray_real_T
{
double *data;
int *size;
int ...
0
votes
0answers
52 views
Simulink Coder - rtGetNaN() rtIsNaN()
I have a really complicated SIMULINK model (that is why I don't want to post it here) and I would like to BUILD it (i.e. through CTRL+B shortcut). When I do I receive the following error. I know it is ...
1
vote
1answer
53 views
Polymorphism in MATLAB Coder
In MATLAB, inheriting from matlab.mixin.Heterogeneous for the base class will allow nice polymorphism. However, it appears this isn't supported in Coder. First, can anyone confirm that Coder cannot ...
2
votes
2answers
69 views
Solving ODEs inside a Subsystem in Simulink
I'm trying to figure out how to solve a system of ODEs inside a subsystem in a Simulink model. Basically, each call to this subsystem, which happens at each tick of the simulation clock (fixed-step), ...
2
votes
1answer
69 views
Matlab Codgen eig() function - strange behaviour
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 ...
1
vote
1answer
83 views
Convert vector<> to emxArray_real_T in C++ after code-generation from MATLAB
I have converted some matlab code to C++ using the MATLAB coder.
I am aware that there are some questions similar to this one, but none of the explanations I found did help with my problem, which is ...
0
votes
0answers
17 views
How do you call a packaged C++ function in V8?
We have a MatLab function, converted to C++ with MatLab coder, and a script in V8 that accepts some inputs, passes these inputs to the C++ function, and is meant to return an array of doubles:
1, 2, ...
2
votes
1answer
63 views
Does Matlab Coder produces single threaded C applications only?
Is Matlab Coder only able to produce single threaded applications?
I attempted to convert some Matlab scripts, used for image analysis, and found that the code produced by Matlab Coder was much ...
0
votes
1answer
92 views
Can't create a .dll from Matlab Coder
I am trying to convert some matlab code into a c dynamic library (.dll) using the Matlab Coder tool. I'm trying it on some simple sample code, but I keep getting the same error which I can't find a ...
2
votes
2answers
60 views
MATLAB roots function different behavior in MATLAB then Simulink?
I implemented the following user defined function in MATLAB:
function Q = Calc_Q(Head, freq)
b6 = [3.7572E-07 -1.5707E-05 6.0490E-03 5.0018E-02 2.1180E-01];
b5 = [-9.0927E-06 8.9033E-04 -3.2415E-02 ...
0
votes
1answer
83 views
UDP in Simulink using Matlab Function Block
I have a server set up with Python, and have successfully set up a simple communication protocol with a client running in a Matlab script. I need to get this function running in a Simulink model in ...
1
vote
1answer
68 views
Is there any difference between a mex file and a function called with coder.ceval?
related
My goal is to use a mix of C code and Matlab code, and ultimately have the whole thing run in C by using the Coder tool.
I've found 2 ways of incorporating C into Matlab, writing a Mex file, ...
0
votes
2answers
39 views
Basic networking with Matlab Coder
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 ...
1
vote
1answer
99 views
switch-case with multiple matches in matlab for code generation
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 ...
2
votes
0answers
72 views
MATLAB to C codegen build error - input properties specification mismatch
I am trying to build a C/C++ static library from MATLAB code, but receive the following error:
"Function 'application' input properties specification mismatch:
expected 0 but found 2."
Here is ...
4
votes
3answers
133 views
Convert integer to string with C++ compatible function for Matlab Coder
I'm using Matlab Coder to convert some Matlab code to C++, however I'm having trouble converting intergers to strings.
int2str() is not supported for code generation, so I must find some other way to ...
0
votes
1answer
28 views
Simulink, matlab functions
i can't find a way to use the same matlab function in more Simulink block. I used function block but in this way each time a have to copy all code changes. What is the best way to this?
0
votes
0answers
26 views
Matlab Codgen: Build error: 'lcclnk64' is not recognized as an internal or external command, operable program or batch file
This question is on error occurring while C code generation from MATLAB Script.
I want to convert my MATLAB script to standalone executable file. When I ran my file (Code_check.m) with 'codegen' ...
0
votes
0answers
32 views
Matlab to C with Matlab coder for streaming data
I am using convolution function in Matlab to verify my algorithm. When I convert this to C code to be run in an embedded system, I want it to process real time data coming from a sensor input, i.e. 1 ...
0
votes
0answers
110 views
Generating C code using Matlab Coder with Visual C++ Compiler
I'm trying to generate code using Matlab Coder, and I've managed to get to the stage where I generate MEX to test the code for run-time issues. However I'm getting a strange error:
Build error: ...
0
votes
2answers
33 views
Using coder.extrinsics conditionally
This question refers to Matlab coder extrinsic functionality. Some functions like fprintf are extrinsic in older Matlab version, and are not extrinsic in the newer ones. Is there a way to support ...
0
votes
0answers
79 views
converting matlab code to c code readiness error
I want to convert my matlab code to c code.But when i am trying to do do lots of warnings are comping in the code readiness report. Although I have sorted out a lot of issues but still there are some ...
1
vote
2answers
130 views
How can I ensure an emxArray is correctly allocated in generated C code?
I have the following .m file (named testmemoryallocation.m), targeted for code generation in Matlab Coder. This is just a test file demonstrating the concept, of course.
function output = ...
0
votes
0answers
97 views
Structure as output of MATLAB Function Block through Simulink.Bus object
I have a MATLAB Function Block where I compute X variables that I want to use later in a script.
My first option was to use To Workspace blocks for each of them, but since I have X variables, it ...
0
votes
1answer
147 views
Reshape function output size is unknown
I am using Matlab coder to compile some .m files into C static library. In the function below, I am getting the following errors:
function net = mlpunpak(net, w)
nin = net.nin;
nhidden = ...
1
vote
0answers
164 views
Matlab Coder; Subscripting into an mxArray is not supported
Using matlab coder, I get Subscripting into an mxArray is not supported. error in the following function:
function net = mlpunpak(net, w)
% Check arguments for consistency
errstring = consist(net, ...
1
vote
0answers
69 views
matlab interp2 with coder
I am trying to generate a mex file from my code using matlab's coder. I'm using interp2. Only when running the mex file I get an error "Grid values must be strictly increasing."
It seems that the grid ...
0
votes
1answer
108 views
Using Matlab Coder generated C files on Qt Creator
I am trying to use Matlab Coder generated C code on Qt Creator. However, whenever I try to build my project, I get an undefined reference error.
Here are some details about the setup:
I set the ...
0
votes
2answers
127 views
Matlab audioread/audioplay into C/C++ through Coder
I am working on a matlab project where I add effects to audio files (mp3, wav). Therefore, I load the files into arrays using the matlab function audioread(..).
Now, I want to export this to Android. ...
0
votes
1answer
146 views
MAP must be at least 'm x 3 array' error in MATLAB
I am trying to generate C code with the MATLAB Coder. The input to the function is an image that has been processed by imread within MATLAB. Since the output should be an m x n x 3 array from imread, ...
2
votes
1answer
202 views
Alternatives to extrinsic functions such as imread and other functions during code generation in MATLAB
As you may know, extrinsic functions are not outputted during the code generation process. Are there alternatives to these functions and/or solutions to this problem? My code generation error report ...
1
vote
1answer
75 views
Problems with using mxarrays with the step function in MATLAB Coder
I'm trying to convert my image processing code on MATLAB into C by using MATLAB coder. using imread needs a coder.entrinsic declaration. However, this means that the output to imread will be an ...
3
votes
2answers
205 views
Output argument not assigned on some execution paths
I am trying to run MATLAB Coder to transform a MATLAB .m file into .mex to hopefully run the code more quickly. When trying to build the file via MATLAB Coder engine, I get the following error:
...
1
vote
1answer
288 views
Convert Matlab m files into C/C++ codes using Matlab Coder, including mex files (mxArray)
I'm using Matlab Coder to generate C/C++ codes from a matlab .m file, which calls external C/C++ functions. I did some work and found "code.ceval" made it worked.
But it gets complicated when the .m ...
0
votes
0answers
186 views
Simulink Matlab Function Block 'Size mismatch' Error
I am using a Matlab function block in a Simulink model. The Input is a 1x32 binary stream and the Output y is an integer between 0 and 15. I have 2 variables defined within this function called ...
0
votes
1answer
120 views
Function/s equivalent to “bwareaopen” and “bwconhull” supported for C / C++ code generation (MATLAB)
This is with reference to a code suggested by Image Analyst given here. I am trying to generate C code for the algorithm. According to the document "Functions and Objects Supported for C and C++ Code ...
0
votes
0answers
41 views
Matlab Mupad algo to M function to Simulink
I am looking at Matlab’s Simulink to build algorithms to eventual systematic models.
My workflow:
Mupad to build the algorithm
Convert it to a Matlab M function
Then import that Simulink using a ...
8
votes
1answer
123 views
How to identify places in MATLAB where data is stored outside the bounds of an array?
I am trying to use MATLAB Coder to convert code from Matlab to a MEX file. If I have a code snippet of the following form:
x = zeros(a,1)
x(a+1) = 1
then in Matlab this will resize the array to ...
1
vote
1answer
118 views
Creating standalone butter filter with Matlab coder
i'm trying to compile with Matlab Coder a custom function which includes a butterworth filter.
I've extracted the lines that give me problem with the Matlab coder function.
function [output] = ...