274 questions
2
votes
1
answer
149
views
MATLAB Coder friendly code for local maximum over 2d array
I am after a MATLAB code which marks each point in a 2d array (image) if it is a local maximum over a 3x3 neighborhood.
The MATLAB code will be used to generate a c code using MATLAB Coder.
A vanilla ...
1
vote
1
answer
814
views
Automatically copy/generate `tmwtypes.h` dependency when generating C code
I am using Matlab Coder to generate C code to be used as a subsystem of a larger C project. A first attempt at a code generation command would be
codegen -config cfg -o ...
where cfg is the name of a ...
0
votes
0
answers
68
views
Is it possible to pass a video recorded with Android camera to MATLAB-generated C++ function in order to process it?
I've developed a video recording app in Android with Camera 2 in order to develop some experiments of imagem processing.
Since now, my approach to process videos was to download it from emulator and ...
1
vote
1
answer
220
views
How can I call a .C function compiled with Matlab Coder in R?
I would like to call a C function compiled using Matlab Coder in R for later use in a Shiny app. How can I go about doing this. The top of the .C function looks like this:
double ...
1
vote
0
answers
56
views
C++ OpenCV Matrix conversion into coder::array unsigned short
I read a DICOM image into an OpenCV matrix, I need to store the pixel data into coder::array<unsigned short, 2U> array because I have a C++ code generated function (using MATLAB) that takes this ...
1
vote
0
answers
31
views
How to convert MATLAB Coder C Code to MATLAB Original Code [duplicate]
I have C Code generated from MATLAB Coder. I lost the SimuLink model that generates this code. There is any form to do the inverse process? That means, convert the previously C Code generated from ...
0
votes
1
answer
151
views
What is MATLAB's algorithm to calculate histogram with hist function?
I'm working on translation of some old MATLAB code to C++. I have noticed, that my custom function to calculate histogram that supposed to be equivalent to MATLAB [counts,centers]= hist(___) gives ...
1
vote
0
answers
248
views
bwboundaries() C++ code Generation Error?
I have enabled dynamic memory allocation in Simulation Target>Advanced with default threshold as 0. Then I attempt to run this code:
B={{nan}}; %%Defining so that it can be set as size variable.
...
1
vote
1
answer
69
views
what is a GR image?
My teacher has assigned me to work combine RGB channels and create a GR image, whose results are like a negative image as shown here:
I have tried the following code:
GR1=(double(100*green_channel/1+...
0
votes
0
answers
314
views
matlab coder report Size mismatch (size [0 x 0] ~= size [1 x 2])
I tried to use matlab coder to convert my matlab file into C\C++ source file. In my *.m file,I defined a dynamic array:
...
...
coord_list = [];
I_list = [];
...
for i=1:n
....
coordinate = ...
2
votes
1
answer
468
views
Matlab Coder force boolean_T to be native C99 bool type
How can I force matlab embedded coder to set "boolean_T" as "bool" C99 type?
Without that, I need explicit cast conversion I/O signals mapping for int->boolean_t (not needed for ...
-1
votes
1
answer
179
views
C++ SIGTRAP on allocate array [duplicate]
the toolchain I use is Clion MinGW Bundle
the original code was generated by matlab
Why SIGTRAP occured when tried to allocate memory?
#define CODER_NEW(T, N) new T[N]
void reserve(SZ _n) {
if (_n ...
0
votes
1
answer
231
views
How do I implement matlab code on hardware device to make it run?
My question is quite basic to most appropriate levels on consideration. I lack the perception of how can I dump or implement my matlab code on a hardware component like processors or fpga? For eg:
...
1
vote
0
answers
125
views
How to fix a Size Mismatch error in MulticlassECOC SVM Model code generation?
For my project, I have been generating ClassificationECOC models and using the Matlab Coder framework to generate C code from them. The methodology for this is laid out in the loadLearnerForCoder ...
1
vote
0
answers
136
views
Casting data to C struct from array in Python
I am writing a test program to evaluate a function written in MATLAB and converted to C code by the MATLAB Coder. This function takes complex inputs, and I'd like to use CFFI to cast this data from a ...
0
votes
1
answer
180
views
MATLAB matching columns/tables
I have two tables:
Table 1 has two columns called WP_1 and WP_2.
Table 2 has three columns called WP1, WP2 and WC.
For every pair (row) of WP_1 and WP_2 I want to check if they are within any pair (...
0
votes
1
answer
166
views
MATLAB Coder syntax errors and unsupported functions
I'm trying to generate my MATLAB code to C. I have some issues about unsupported functions. Are there any alternative functions for 'mkdir', 'fileattrib' and 'dlmread' functions in MATLAB Coder?
1
vote
1
answer
347
views
Why does MATLAB Coder not generate C built-in types even though I've set DataTypeReplacement = 'CBuiltIn'?
I have a MATLAB (R2020b) function that I am trying to convert to (Linux-compatible) C program using MATLAB Coder. The function accepts 3 string arguments like so:
function func1(a, b, c)
I would like ...
0
votes
0
answers
166
views
C++ conversion for unique function using MATLAB coder
I am trying to convert this simple MATLAB function to C++ using MATLAB coder:
function uniqueC_conversion()
a= [1 0 1 2 4 5 1]
b=unique(a)
end
The output is like this:
//
// uniqueCPP.cpp
//
// Code ...
1
vote
1
answer
1k
views
Error in Matlab Coder: Index exceeds array dimensions
I am trying to convert .m script to C++ using MATLAB Coder.
function P=r_p(1,var1,var3)
p=[[3,7]
[10,15]
[6,19]
[21,19]
[43,11]
[969,2]
[113,9]
[43,59]
[21,15]
[6,15]
[10,18]
[3,15]];
...
0
votes
1
answer
296
views
GPU Coder in MATLAB for heavily object oriented code
I am working with a heavily object oriented code in MATLAb. I want to use GPU coder to accelerated the code. However GPU coder only works for functions and the argument of the function should be ...
2
votes
2
answers
313
views
How to pass structures into re-integrated autogenerated C++ code in Matlab
I am trying to test some code that has been generated from Matlab into C++.
To do this I am attempting to integrate and run the generated C++ code back into Matlab.
Here's the function I am trying to ...
1
vote
1
answer
453
views
Using custom C structures with MATLAB coder
I need help initialising and using custom C structs in MATLAB. My goal is to write MATLAB code utilising external C structures and functions. The resulting MATLAB code with these C structures will be ...
0
votes
1
answer
109
views
Is it possible to use Matlab Coder to get a C version of an inbuilt Matlab filter design function?
I'm specifically looking at something like Matlab's firpm function (I know there are C implementations of Remez available online in several sources).
0
votes
1
answer
910
views
No rule to make target '-L/usr/local/lib'
I am facing a problem while trying to link opencv to CPP project generated by Matlab Coder. In the auto generated Makefile of the project, I added pkg-config --cflags opencv to CFLAGS and pkg-config --...
1
vote
1
answer
166
views
why does strel failed in MATLAB Coder
Using MATLAB Coder in 2019b, the following line:
se = strel('line',20,85);
that MATLAB Coder is unable to effectively describe:
1.All inputs must be constant.
2.Function call failed
why is Coder ...
2
votes
1
answer
1k
views
Can MATLAB Coder generate a function that takes a pointer as input?
I would like to use MATLAB Coder to generate an executable (or a function in an object file) that accepts a pointer to an array as an input.
I used libpointer to create a pointer object and then tried ...
1
vote
1
answer
1k
views
Matlab coder: How to force a variable to have variable :inf size
I can't find how to force Matlab coder to make a parameter size be variable rather than fixed.
Here is a MCVE:
Function code:
function [sz] = my_varsize(x)
sz = length(x);
end
Sample main ...
3
votes
2
answers
92
views
Variable named i386 generated by Matlab Coder
I'm generating code for a function with several variable-sized arrays. The code needs to be compiled in both linux (with gcc) and windows machines (with MinGW).
To "ensure capacity" in those ...
1
vote
2
answers
1k
views
Matlab coder: "All inputs must be constant"
I'm using Matlab Coder to convert this code to C++:
fs = 50;
[b,a] = butter(3,0.5/(fs/2),'high');
...
% Other code using fs
Then, I get this error: "All inputs must be constant".
If I do: [b,a] = ...
2
votes
1
answer
2k
views
How to force Matlab/Simulink Coder to use the parameters created in simulink
I have a simulink model using matlab function blocks.
When i try to generate the C code from my model, the structures parameter scopes i used to represent my data are unused :
When i say unused i ...
0
votes
1
answer
872
views
How to import a header file to load constant values in Simulink? (for generable code)
I'm developing a Simulink model with many constants.
I'm trying to:
Avoid hardcoding every constant in the model and have something unreadable.
Be able to know what that 9.73288483... constant in ...
1
vote
1
answer
468
views
MATLAB to C++: csvread() not supported by MATLAB Coder
I need to port a MATLAB script, which uses .csvs to read and write configs and data with csvread(), to C++.
Obvious choice was to use the Coder app in MATLAB but csvread() is not supported by Coder.
...
-1
votes
1
answer
416
views
How can I Convert M-file to RISC-V Assembly code?
I am new to RISC-V. I want to convert that MATLAB code(M-file) to RISC-V Assembly code, can anyone give some suggestions or inputs on how can I do it.
Regards,
Yulia
1
vote
1
answer
176
views
matlab coder requirements stricter than normal matlab
Consider the following matlab program:
function results = prog()
opts.x = 1;
if ~isfield(opts, 'y'); opts.y = 1; end
'asdf'
return
I am able to run this program successfully in matlab ...
2
votes
0
answers
146
views
Interfacing MATLAB C files obtained from MATLAB Coder with Python
I am trying to convert some of my MATLAB files to Python. I generated C code using the MATLAB Coder, then compiled everything in a library. I am now trying to make the wrapping for Python.
It looks ...
0
votes
2
answers
1k
views
Using Relative Paths with Matlab Coder
I am trying to generate C code for a Matlab function. It uses mongoose web server for communication. If I place the .h/.c files in the same folder as the .m file I can compile everything fine using:
...
1
vote
1
answer
2k
views
Forcing Matlab Coder to create structures
I had one structure in my code which was created with a function create_a_structure.m with a_struct = create_a_structure(). Several other functions either called this function, modified the values in ...
2
votes
1
answer
768
views
Can MATLAB C generation coder generate C-code that fits embedded system?
I need to convert this code into C code.
Questions:
Will MATLAB Coder generate C code that are memory safe, e.g they not using calloc or malloc. Misra C standard does not allow coder to use dynamical ...
0
votes
0
answers
109
views
Problem printing predict output in an C++ code generated using MATLAB Coder
I translated my MATLAB code to C++ using MATLAB Coder and I changed the main.cpp to create a executable. Everything seems ok until here, but when I print my predict output, my classname has an extra ...
1
vote
1
answer
184
views
emxFree_real_T Causing Executable to Abort
I'm working with Matlab coder, using variable size variables pointed out with coder.varsize. This causes some variables to be declared with the type emxArray_real_T, be initialized with emxInit_real_t,...
1
vote
1
answer
354
views
How to test object code In Python environment. Inputting a preferred test case
I am looking for procedure or suggestions if this is do able or not.
I have source files or (object code) which is compiled on a MATLAB environment using embedded coder. Now I want to bring those ...
0
votes
1
answer
187
views
Converting a C char array into a Matlab String [Matlab Coder]
My intention is to show for the output of Matlab System a string the type char_T data[ ], that I receive a function in C through coder.ceval
I want to show more specifically the buffer variable, as ...
2
votes
2
answers
601
views
What is the right way to work with Matlab coder dynamic and static allocations?
I recently started working with Matlab coder for building computer vision algorithms. I'm working on a point cloud classification problem which means that my algorithm input is a set of 3D points (x,y,...
0
votes
1
answer
295
views
Create constant for specifying array size in MATLAB Coder
How can I create a constant variable in MATLAB (and its results the generated C code), so I can use it later in my code to specify the size of variables.
I want to have an array that its size is not ...
2
votes
1
answer
121
views
how to generate MEX from package function in MATLAB?
I have the following directory structure:
main
+model
run.m
+options
opt.m
main.m
and so forth.
I have a function under +model directory called run that depends on some functions ...
0
votes
1
answer
83
views
MALAB Coder - Static size string in sprintf
How can I prevent MATLAB Coder to generate variable size code for a simple number insertion into a string?
for i=1:4
name=sprintf('Data%d.bin',int8(i));
stuff(name);
end
In the generated C ...
5
votes
2
answers
950
views
Adjacent and non-adjacent superpixels for an superpixel in an image
After segmenting an image into N superpixels, I need to specify the superpixels that are adjacent or non-adjacent to one superpixel and determine this relationship for all superpixels.
[L,NumLabels] =...
1
vote
2
answers
560
views
MATLAB/Embedded Coder File Loading
I generated code for loading a mat file as follows
data=coder.load('data.mat');
a=data.a;
b=data.b;
Because one of the variables, for example "a", is very big, it is defined as a big static const ...
1
vote
1
answer
628
views
String comparison on cell array of strings with Matlab Coder
I am trying to use the MATLAB Coder toolbox to convert the following code into C:
function [idx] = list_iterator(compare, list)
idx = nan(length(list));
for j = 1:length(list)
idx(j) = strcmp(...