How can I get the alternatives for the functions Not supported by Matlab Coder?
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Benson Gou
el 23 de Jul. de 2021
Comentada: Benson Gou
el 24 de Jul. de 2021
Dear All,
I want to convert my Matlab code into C language using Matlab Coder. But I got the following functions which are Not Supported by Matlab Coder. I have to find the alternatives for those functions. The functions are:
exist, sscanf, regexp, mkdir, cd, addpath, str2num, quit, ismembc, mat2cell, cellfun, split.
Does anyone have an idea how to get the alternatives for above functions?
Thanks a lot in advance. You all have a good weekend!
Benson
2 comentarios
John D'Errico
el 23 de Jul. de 2021
There may be good reasons why some of them are not supported. You would need to write those codes yourself, from scratch. Good luck on some of them. :)
Respuesta aceptada
Steven Lord
el 24 de Jul. de 2021
which exist
There is no purely MATLAB code equivalent for this. You could probably use file I/O functions in C to check if the file exists (does opening the file succeed?) See the section on External Code Integration for how to call C or C++ functions from your MATLAB code. See in particular the examples on the documentation page for coder.ceval for how to call MATLAB code when you're not generating code and C code when you are.
which sscanf
I think you could substitute scanf in C. Alternately you could parse the char vector yourself and use str2double to turn character vectors representing numbers into numbers.
which regexp
There is no purely MATLAB code equivalent for this. Any such MATLAB equivalent you would write would likely be quite complicated, unless you targeted it solely at the portion of the regular expression language you were using.
which mkdir
There is no purely MATLAB code equivalent for this. C has the capability to create directories.
which cd
I'm not sure C really has the concept of a current directory, so you're probably going to need to rethink this.
which addpath
While this is in MATLAB code, C doesn't have the concept of a MATLAB search path. You're going to need to rethink this.
which str2num
Consider str2double instead.
which quit
There is no purely MATLAB code equivalent for this. Just have your application exit.
which ismembc
You could write a set membership function that loops through the two vectors, but you would need to write that.
which mat2cell
This is MATLAB code, but I think how to convert it would depend on what you're doing with those cells.
which cellfun
See mat2cell.
which split
This could probably be done via a loop, but again what are you planning to do with those cells or with that string array?
As for your question "Do you think if it is possible for me to get the Matlab code of the above functions?" most of those are not implemented using MATLAB code. For those that are, the solution is unlikely to be as simple as copying the text of those functions in place of the function calls in your application.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!