274 questions
2
votes
1
answer
3k
views
Matlab Coder using boolean_T
I'm trying to generate C code for a simple function Matlab funciton:
function[] = myfunc()
%#codegen
fprintf('Executing myfun\n');
fid = fopen('file_created_by_myfun.txt','w');
fwrite(fid,'This is ...
-1
votes
1
answer
84
views
Datatype conversion?
Given a Differential Equation in matrix form:
f = @(t,y) [(a*y(1) + b*y(2)); (c*y(1) + d*y(2))];
a=-2; b=-1; c=1; d=-4
Solutions to my differential equation problem are
x(t)= e^(-3t) (t+1)
y{t)= e^(-...
1
vote
1
answer
618
views
Forward declaration of anonymous typedef struct C++
I have a C++ dll with a header file that is refrencing some generated (Matlab coder) anonymous structs. I am trying to forward declare theese structs in order to avoid including more than the main .h ...
4
votes
1
answer
400
views
Cannot convert Matlab code to C code using Matlab Coder
I have a MATLAB code shown in below. I am trying to convert this code to C code using MATLAB Coder but I encountered an error.
Expected either a logical, char, int, fi, single, or double. Found an ...
1
vote
0
answers
353
views
MATLAB compiled C++ library error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
I tried to use a MATLAB coder compiled C++ library in vs 2017 but encountered the error below:
1>test_cv_2.lib(test_cv_2.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '...
0
votes
1
answer
229
views
How to use trained neural network as function using MATLAB coder?
I've trained a simple neural network that just multiply 4 numbers and gives 1 number as an output.
( output(x0) = in1(x0)*in2(x0)*in3(x0) *in4(x0)).
or
description:
My neural net has 4 inputs, and ...
1
vote
1
answer
395
views
Generated C++ code using MATLAB Coder : Compilation Error "undefined reference to `rgb2gray_tbb_real64'"
Generated C++ code from MATLAB for converting an image to grayscale, using MATLAB Coder. While compiling it on Dev C++ it shows error- undefined reference to rgb2gray_tbb_real64
One of the Generated ...
2
votes
1
answer
343
views
Matlab code generation of resample: the number of terms N must be constant
I use Matlab coder to generate C code of the following function:
function [out] = myresample(in)
out = resample(in,4644,1000,10);
end
and generate the code by codegen myresample -args {coder....
0
votes
1
answer
343
views
How to manage automatically generated c-files from matlab coder?
I have an existing dll with multiple functions, let's call it mylib. I decided to use matlab coder to help me write my c-files. These c-files are compiled and linked to generate mylib using VS 2015.
...
1
vote
1
answer
236
views
Loading DLL generated by MATLAB Coder with function, that calls outer functions
I have a DLL file, generated by MATLAB Coder, that contains function Adjust. This functions calls for few outer functions written in outer .m files, e.g PulseFindAdapt:
function [Indexes,...
2
votes
1
answer
227
views
MATLAB Emebedded C function issue
Hi I am trying to use C files in MATLAB through MEX-files but so far no luck. I followed the tutorial shown in this link: https://uk.mathworks.com/videos/integrating-matlab-into-your-cc-product-...
0
votes
1
answer
350
views
matlab coder - change format in created C code
I am using Matlab coder to port code to C, e.g. for the next function:
function sum_out = my_sum( x )
sum_out = 0;
for i=1:size(x,1)
sum_out = sum_out + x(i);
end
end
The generated C code is:
...
0
votes
2
answers
932
views
Using fftw3 with fftw complex type
I am using MATLAB coder to generate code which deals with complex numbers. The default typedef for the complex type generated by MATLAB is:
typedef double real_T;//real number
typedef struct {
...
0
votes
1
answer
317
views
Error detected from emxArray_uint8_T: .text+0xc1): undefined reference to `emxInit_uint8_T1(emxArray_uint8_T**, int)'?
I write a matlab function that calculates entropy of gray scale image: "score=score_entropy(image)" then use matlab coder to convert it to c++
c++ code:
#include "mex.h"
#include "math.h"
#include "...
3
votes
1
answer
1k
views
error: ''cannot convert 'uint8* {aka unsigned int*}' to 'const emxArray_uint8_T*'?'?
I have written a matlab function to calculate entropy of image "ent=entropoy(image)" and convert it to c++ function by matlab coder.
I do some calculation at ent in c++ file then try to convert all c+...
1
vote
1
answer
3k
views
Convert MATLAB to C++ using MATLAB coder
I'm going to convert a MATLAB code "full of operations on matrices " to C++ ,I'm not sure if MATLAB coder would generate an efficient C++ code.Is it better to convert it by hand although it's so time ...
0
votes
1
answer
82
views
Issues with arrays and matlab coder
I've been working on creating c code with Matlab-coder. I have a function called melfunction that gives an error for line 20 of the code below.
function [ c ] = melfunction( x )
bank=melbankm(24,...
0
votes
0
answers
598
views
Why MATLAB Coder can't build MEX?
I have a problem. MATLAB Coder doesn't work properly with one of my projects. At Check For Issues state it generates error "MEX build failed". But it doesn't generate any error message. Target Build ...
0
votes
1
answer
302
views
Adding the MATLAB CODER generated C in Android Studio
I have trouble in importing the generated code of matlab coder in android studio. Can someone help me in importing C?
Screenshot of Folder with the .h and .c files
When Matlab generated the C code, ...
2
votes
0
answers
39
views
Does Matlab Coder has a issue to short a vector with ja variable?
I have a Problem in Matlab Coder. So, Im trying to short a vector with a variable.
[aa,a] = min(array(:));
idx=single(a(1,1));
b= c(1:idx,1);
Error:
Could not determine the size of this expression.
...
2
votes
0
answers
772
views
Converting a dynamically sized mxArray to struct in Matlab Simulink
I have an extrinsic function that returns an mxArray through webread(). This mxArray should actually be a struct, so that I can access it and read the data in it. The problem is that it has a dynamic ...
0
votes
1
answer
382
views
How can I deploy a matlab code that saves .mat files files to communicate between functions, and saves data in the local directory
I wrote a GUI in matlab using GUIDE and I am using a data structure that is saved as a .mat file in the local directory of the matlab application. the .mat file is used to transfer variables between ...
0
votes
0
answers
1k
views
Manipulating block parameters in Matlab Simulink model with inputs
I've created a matlab model with intentions to use it for code generation, specifically with the PLC coder. The model is basically the example discrete PID block with the error calculation included, ...
0
votes
0
answers
339
views
How can I modify this code so that canny edge detector can detect this red mark line?
I take an image using Microsoft Kinect. But all time canny edge detector missed that line. I don't know why? how can I detect this line? I attached here raw depth image & output of canny. Don't ...
0
votes
0
answers
252
views
matlab compile to C: detect slbuild vs coder
Apparently slbuild has severe limitations on the size of arrays that it supports. MATLAB Coder gives me options to convert those to dynamic memory. I don't see how to do that with 'slbuild'. However, ...
1
vote
2
answers
1k
views
csvread function supported by MATLAB coder
I have a MATLAB script that contains a csvread call to read in data from a csv file. Now I'm trying to compile my MATLAB script into C using MATLAB Coder. However, csvread is not a member of the ...
0
votes
1
answer
82
views
Error determining type for input 'conscalc: calc '. Cannot union coder.StructTypes with different sets of fields
When I try to convert a Matlab program as a group which includes several functions to C++ program by Matlab coder app, I get a error says this:
enter image description here.And variable calc is a ...
3
votes
2
answers
271
views
Operating on arrays using Unsigned Values [closed]
I have been generating a C function from Matlab Coder environnement in order to implement it in an other software called MAX/MSP.
I'm trying to make sense of it, thanks to my poor level in C ...
1
vote
0
answers
234
views
Matlab emxArray_real_t Assignment in C++
I've Converted Some Matlab Code to C++ using Matlab Coder Tools.
I have declared 2 arrays like This:
emxArray_real_T *overflowIF
emxArray_real_T *overflowIFTemp
overflowIF = ...
0
votes
0
answers
94
views
Replacing sparse matrix inserting operation in Matlab by C++
I am using a optimization toolbox in Matlab R2016a. But it runs very slow. I find that the main reason is the sparse matrix indexing operation when the size of sparse matrix becomes more than 100000.
...
0
votes
1
answer
430
views
Using MATLAB coder to export code from Registration Estimator app to C++
Hi I'm trying to export "the default code" that is automatic generated from the Registration Estimator app within MATLAB to C++ using the MATLAB Coder tool.
This is an sample code I ...
0
votes
1
answer
297
views
How can I draw a vertical line upon the horizontal lines in matlab?
I want to draw a vertical line in Matlab upon the concurrent horizontal lines and show the coordinates where the vertical line intersects the horizontal lines.I give a figure here, I want to write a ...
1
vote
1
answer
465
views
Using a variable-sized argument in Matlab coder
I want to generate a c++ code for DCT function using Matlab coder. I wrote this simple function and tried to convert it to c++.
function output_signal = my_dct(input_signal)
output_signal = dct(...
0
votes
1
answer
378
views
View code generation readiness issues , c code generation from Matlab function
I got some issues while generate the 'C' Code from Matlab Function.Issue like this "Unsupported MATLAB Function calls" & "Code generation tools may fail unless the issues listed below are fixed". ...
0
votes
0
answers
99
views
Matlab: imcrop throws error while C code generation
in matlab while compiling to c code imcrop failed to run.
is there is any alternative method or any way to suppress?
I am using Matlab2016a. Below is code snippet:
if ~isempty(bbox);
bbox = bbox(...
0
votes
0
answers
306
views
Running a Matlab standalone application on Raspberry pi
i have make a standalone application with Matlab Compiler. Now i want to run this application on my Raspberry pi (model 3b). Is this possible? This application is just a GUI to calculate some values.
0
votes
2
answers
66
views
I have matrix of 200*10 it has values between 50 and 150 I have to normalize it that is I want to see values less than one [closed]
I have a matrix 200 *10 having values between 100 and 150 and I want to have values of between [0 1] that's it.
I know one way of doing is to divide it by max value but I want to know any other way i....
0
votes
0
answers
84
views
Matlab Coder, Cell Array Not Fully Defined
I have built the following function:
function [obs,dw,rot] = myfun(T,obs,dw,dt,rot)
if rot == 0
v = (0:dt:T(1)-dw);
obs{1} = v./T(1);
dw = (dt+v(end)-T(1));
for i = 2:numel(obs)
...
1
vote
1
answer
1k
views
Converting .m file to binary executable [duplicate]
I need to create standalone executable files out of .m Matlab files. I have Matlab 2016a under university license. Seem I have these options:
1) MCR
2) Matlab Coder
3) Matlab Compiler
However I ...
2
votes
0
answers
305
views
How to measure time within matlab generated C/C++ code
I have some matlab code that I use to generate C++ code with, using codegen. I want to check the execution time of a single function within this code. Normally I would use tic and toc but these ...
0
votes
2
answers
437
views
How can I initialize variables at runtime using the matlab coder?
I have a function that I export with the matlab coder to C++ code. In the code a matrix is loaded from a mat file. I was using:
coder.load('filename.mat');
However this does not allow me to change ...
0
votes
1
answer
308
views
How to specify function signature for function handles in MATLAB code generation?
I want to compile a MEX from a function that has the following code (MATLAB R2015a):
function r = MyFunc(x,type)
ind = randi(numel(x), 1);
getInd = @getIndFixed;
if strcmpi(type, 'random')...
0
votes
1
answer
637
views
Converting a C char array into a Matlab String using Matlab Coder
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 ...
1
vote
1
answer
146
views
Using Matlab Coder generated algorithm for Production
I have a fine tuned algorithm in MATLAB that operates on matrices (ofcourse). I've used matlab coder to generate c code for this algorithm and it works as expected.
Here's a function call that I used ...
2
votes
0
answers
160
views
defining output as unbound (1x:inf) vector for matlab coder
I'm having trouble defining a vector to be unbound when i use the Coder to generate C code. I wish to have a vector of type double 1x:inf, that will later generate a pointer to a struct containing the ...
0
votes
3
answers
827
views
Matlab Coder and Arduino IDE emxCreateWrapper_real_T
I builded a neural net in Matlab and created a function, which uses the NN. I genereated C++ code from that function to use it on my Arduino Yun.
In the Arduino IDE I first wrote #include "...
0
votes
1
answer
638
views
Matlab coder error "for loop index expressions.." how to modify code?
On Matlab coder I get the error "FOR loop index expressions of unknown size are only supported if they are of the form A:B or A:B:C" whenever I use for indexing a vector in a for loop, example:
for e=...
2
votes
1
answer
350
views
Non-recursive implementation of perms in Matlab, compatible with Coder
I am trying to convert part of my function in matlab into c++ using coder. Coder doesn't support the function perms. I extensively use perms in my code. After looking online I found few suggestions of ...
1
vote
2
answers
765
views
how to use generated code from matlab
I want to use the C-coder in Matlab. This translates an m-code to C-code.
I use a simple function that adds 5 numbers.
When the code is generated there are a lot of C- and H-files.
of course you could ...
2
votes
2
answers
2k
views
MATLAB Coder hello world start to finish
Edit
After going through this much effort only to produce faulty .exe files we have decide to not spend more time trying to generate the code and to instead write it ourselves. Thank you all for your ...