Is it possible to use Matlab Coder to get a C version of an inbuilt Matlab filter design function? - matlab

I'm specifically looking at something like Matlab's firpm function (I know there are C implementations of Remez available online in several sources).

The firpm page on the MATLAB documentation, under "Extended Capabilities", says the function is compatible with C/C++ code generation with the MATLAB Coder.

Related

Browse MATLAB integrated functions

I tried to find the source code for some integrated MATLAB functions. Is there any way to find MATLAB's integrated functions? For example I can't find hypot source code.
Most MATLAB functions are supplied as MATLAB source code, and you can view the source by typing edit <functionname>. Some of the lower level functions, however, are implemented in C for better performance and are built-in - you can't see the source code. hypot is one of these.
However the algorithms are not typically that secret - you can read an article about hypot (including the algorithm) on Cleve Moler's blog.

How to call function from opnet [duplicate]

I have some code that plots triangles in MATLAB.
I need to be able to somehow execute this code from my C program which generates these points.
Is that possible? How can it be done?
Just a thought:
Can I somehow embed MATLAB code in C, so that it can compile on a C compiler?
The Mathworks site has full details; a demo video of calling the Matlab engine from C, and also the Matlab to C Compiler.
As mentioned previously by answerers, you can call a live copy of MATLAB from C via the MATLAB Engine interface.
If the end-product needs to be used where there is no live copy of MATLAB, you can deploy the application using MATLAB Compiler. However, MATLAB Compiler does not, as another answer has suggested, convert MATLAB programs into C code (and hasn't done for a few versions now). Instead, it archives and encrypts your MATLAB program, and packages it into an executable or shared library that executes against the MATLAB Compiler Runtime (shareable royalty-free). The executable or shared library can then be called from C.
Alternatively you could go the other way around, and call your C code from MATLAB, using either loadlibrary or MATLAB's MEX interface.
Update: As of release R2011a, you can also use MATLAB Coder to generate C code directly from a subset of the MATLAB language.
Look at this presentation about integrating MATLAB Algorithms in C or C++ Applications http://www.mathworks.com/videos/integrating-matlab-algorithms-in-c-or-c-applications-86431.html

How do I use built-in MATLAB functions?

MATLAB has lots of built-in functions that I can call, such as "sin" and "norm." However, some of MATLAB's built-in functions are part of different libraries that I cannot access directly. For example, the function "ssim" is part of MATLAB's image processing toolbox, so I cannot simply call "ssim" in my code and have it work.
How do I call built-in MATLAB functions that are in different libraries? Do I need to import the libraries somehow? If so, how do I do that? How do I do this for ssim specifically?
Thanks so much!
Type ver into the command window to see which toolboxes belong to the license you bought.
Any function of these installed toolboxes you can call normally, like the mentioned sin.
Sometimes, if you're lucky, you can find equivalent functions of otherwise expensive toolboxes at MATLAB File Exchange.

Gaussian hypergeometric function 2F1

I would like to know if there is any available Gaussian hypergeometric function (2F1 function) code for Matlab.
I perfectly know that in the newest Matlab releases there is the hypergeom function, but it works really slow.
Therefore I was wondering about the existance of any mex function or whatever similar code performing what hypergeom does.
I thank you all in advance for support.
Best regards,
Francesco
The GNU Scientific Library implements hypergeometric functions including 2F1. You shouldn't have too much trouble wrapping that inside a mex-file.
I expect you'll find other sources knocking around on the Internet too.
Do report back and let us know if it does work faster than the intrinsic function.
After googleing a bit in the Internet, I came up with this tool provided within the Mathworks File Exchange:
http://www.mathworks.com/matlabcentral/fileexchange/35008-generation-of-random-variates/content/pfq.m
It consists of 1900 distributions, and among them the Gaussian hypergeometric function 2F1.
Furthermore, it has better performances than the standard hypergeom function.

convert matlab code to c code

is there s a way to convert simulink blocks or a matlab ".m" code to C code automatically ?
I'm not aware of any direct translation tool, but there are a few alternatives:
Matlab Compiler will let you create a shared library (callable from C code) from your .m code.
GNU Octave is an open source interpreter that has many of the same functions as Matlab. It is open source, and written in C. You might feasibly build a C library based on on this, although it would be a lot more heavy-weight than option (1).
To convert Simulink models or MATLAB m-code to C you need Real-Time Workshop.
It supports only subset of MATLAB language and oriented for embedded systems.
Look also at other MatWorks products for code generation and application deployment:
http://www.mathworks.com/products
With MATLAB Compiler you will not get a C code, but a binary code, executable or library (dll), which will run on machines without MATLAB installed, but with MATLAB Compiler Runtime (MCR) library. It quite large in size, and platform specific and I believe it has to match the MATLAB version of compiled code.
For the new coming release 2011a The MathWorks developed new code generation products: MATLAB Coder, Simulink Coder and Embedded Coder.