MATLAB code that reads in an logic code input file

Is there MATLAB code/pseudocode that reads in a text input file containing basic user-defined logic code (ie, if-then-else, while-do, etc), then MATLAB itself interprets that logic program code and applies that code onto existing data structures within MATLAB. In a way, the MATLAB m-file becomes a run-time compiler for the user-defined text input file. Currently, any logic must be coded into the m-file ahead of time in the m-file. In this way, the logic applied to a data array/structure can be defined on the fly.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Feb. de 2016

0 votos

2 comentarios

Guillaume
Guillaume el 28 de Feb. de 2016
There's also the completely undocumented mtree function that has been part of matlab for a long time. This gives you a parse tree of any m-file.
Figuring out how to manipulate that tree and how to interpret it is a challenge though due to the lack of documentation.
rayjoe
rayjoe el 29 de Feb. de 2016
Guillaume and Walter, thanks for all the suggestions. They give me enough ideas and directions to digest and start with where to go. -raymond

Iniciar sesión para comentar.

Más respuestas (1)

Guillaume
Guillaume el 28 de Feb. de 2016

0 votos

"a text input file containing basic user-defined logic code (ie, if-then-else, while-do, etc)" is the definition of a m-file. It's possible to call a user supplied m-file from your own m-file if you wish. You may have to play around with the matlab path if the file can be located in any directory. (but it's never very wise to run any arbitrary user-supplied code)
Or are you asking for some sort of simplified language that matlab could interpret. There is no such thing built-in and for us to even give you any pointer you would have to first define the grammar of such language.

2 comentarios

rayjoe
rayjoe el 28 de Feb. de 2016
Thanks, Guillaume. yes, I was looking for a simplifed language, or anyone who has created their own simplified logic grammar. Your suggestion to just have the m-file call another user-supplied m-file could suffice for my needs. As you mentioned, that would risk running arbitrary user code.
Guillaume
Guillaume el 28 de Feb. de 2016
Possibly, you're looking to implement a finite state machine engine.
As far as I know, there a toolbox for simulink that does this. (I know nothing about it, or simulink for that matter), but implementing a state machine engine in matlab should not be too difficult.
But again, we need to have an idea of the kind of logic you want to implement.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Feb. de 2016

Comentada:

el 29 de Feb. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by