C Code aus Matlab generieren!

Hallo!

ich möchte aus diesen 4 Zeilen Matlabcode einen C Code generieren lassen. Weiss einer wie das geht?

[X,Y] = meshgrid(1:1:4);
Z=[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
[XI,YI] = meshgrid(1:.5:4);
ZI = interp2(X,Y,Z,XI,YI);

Gruß Alex

Du brauchst dafür den Matlab Coder. Eine gute Videoanleitung ist hier zu finden: http://www.mathworks.de/videos/generating-c-code-fro…

Danke für die schnelle Antwort!

Ich kriege mit dem codegen Befehl leider eine Fehlermeldung:

Could not locate the MEX compiler options file mexopts.bat.
Run mex -setup to select the MEX compiler and create the MEX options file.
Use help codegen for more information on using this command.
Error using codegen

und dann das:

mex -setup

Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/wi…

Please choose your compiler for building MEX-files:

Would you like mex to locate installed compilers [y]/n? y

No supported SDK or compiler was found on this computer.
For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/wi…

Error using mex (line 206)
Unable to complete successfully.

So! Nun hab ich den Compiler installiert und der wurde auch von Matlab erkannt:

Select a compiler:
[1] Microsoft Software Development Kit (SDK) 7.1 in C:\Program Files (x86)\Microsoft Visual Studio 10.0

[0] None

Compiler: 1

Please verify your choices:

Compiler: Microsoft Software Development Kit (SDK) 7.1
Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0

Are these correct [y]/n? y

***************************************************************************
Warning: MEX-files generated using Microsoft Windows Software Development
Kit (SDK) require that Microsoft Visual Studio 2010 run-time
libraries be available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************

Trying to update options file: C:\Users\XE\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\mssdk71opts.bat

Done . . .

**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external…
Building with the -largeArrayDims option enables the new API.
**************************************************************************

>> codegen test
??? Unable to locate function ‚test‘.

Code generation failed: Open error report.
Error using codegen

Hat sich erledigt, musste erstmal eine Mex datei erzeugen!!!

Vielen Dank dmhr!