matlab,cell,simulink,cell-array,matlab-coder

Please read through the MATLAB Code Generation Manual. There, in the General Limitations section, it clearly states that You cannot use cell arrays in your code. The solution to this is presented in the MATLAB Central: You have to replace the cell arrays by e.g. structs. As I see from...

matlab,random,simulink,matlab-coder

The rand being called from your MATLAB Fcn Block is not the same rand as would be called from MATLAB, hence the reason why rng('shuffle'); has no effect on Simulink's random number generation. You could force the MATLAB Fcn Block to use MATLAB's rand function by doing the equivalent to,...

c++,matlab,makefile,static-libraries,matlab-coder

Make it main: $(OBJECTS) $(CC) -o main $(OBJECTS) $(LIBS) # LIBS at the end This is a funny thing with ld and static libraries: It only picks those .o files out of the .a that it thinks it needs at that stage in the linking process. If later objects (main.o...

c,matlab,simulink,matlab-coder

The library format should match the architecture on which you are going to compile the generated code. So .a or .so for GNU/Linux, .lib for Windows (you usually link against the .lib file not the .dll), and usually .dylib on Mac. You can also link in object files, (i.e. .o,...

matlab,matrix,simulink,robotics,matlab-coder

You can't have the last dimension as 1 because MATLAB treats any matrix of dimension [m,n,1] as [m,n]. See size() returns 1 where matrix dimension should not exist for more details. Try defining R of size [n_robots,3,3] and then re-arrange the matrix inside your code (I assume you are using...

Firstly: you can call back into MATLAB from your generated C code or generated MEX file, using coder.extrinsic. If for some reason you have an existing MEX file without source code that you need to call, you can do this in the same way as for any other MATLAB command....

c++,memory-management,memory-leaks,new-operator,matlab-coder

These variables are of scope 'automatic'. The language guarantees that your program will release this storage at the end of the current block. It is probably on the stack, but nothing forces the implementation to use the stack. Bottom line: no leak.

You could write a C wrapper for Foo that accepts a pointer to a struct and forwards the underlying data pointer, MyStruct->VeryLargeArray, to Foo. MATLAB Code passStruct.m: function y = passStruct(x) %#codegen coder.cinclude('Foo.h'); s.f = x; coder.cstructname(s, 'wrapperStruct_T'); y = 10; y = coder.ceval('WrapFoo', coder.ref(s)); Header file Foo.h: /* Include...

matlab,loops,struct,simulink,matlab-coder

When generating code using MATLAB Coder or Simulink Coder, not only are cell arrays disallowed, but also referencing fields of a structure using dynamic names. Since you can't use dynamic names, you should probably just repeat the content of your loop body multiple times, once for each field name, which...

matlab,time,simulink,matlab-coder

You shouldn't be using absolute time in an embedded system, which is at least one of the reasons why tic-toc and clock from MATLAB don't work with Simulink Coder. You should create your own counter, which you start and stop when you need to. This is pretty easy to do...

c,matlab,visual-studio,dll,matlab-coder

Okay.We worked on it and found out the solution.We need to make variations to the Matlab coder project tool chain.We need to add the .res file developed using Visual Studio(Which contains information like version,copyright etc..) to the Shared Library linker after changing the 'Build Configuration' to 'specify'

The issue is in initialisation gesgroup is initialised with size 1x2 but the line gesgroup = [group, horgroup]; will make it 1x4 ( as both group and horgroup are 1x2), you need to initialise it as such or as variable size e.g. gesgroup = zeros(1,4); or coder.varsize('gesgroup') I think the...

c++,matlab,arduino,simulink,matlab-coder

Is the header file containing the declaration of dout_output being included in the C code generated from the MATLAB Function code? If not, you'll likely see compiler warnings that say something about implicit int return type. When C compilers don't have a declaration for a function, they may assume that...

c,matlab,simulink,matlab-coder

Getting the Code to Compile To get the code to compile I added: #include "mystruct.h" in the Simulation Target->Custom Code->Header File section. Adding the required include paths on that pane may be necessary as well. Compatibility Concerns After doing the above, the code crashes when running. The issue is that...

matlab,memory-management,matlab-coder

It's good to see that you're making progress. Regarding the emxEnsureCapacity issue it is unfortunate and it is a bug. I'll take care of it to ensure we fix it in a forthcoming release. Meanwhile, there's a way of patching the generated source code. For config objects there's the 'PostCodeGenCommand'...