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.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Feb. 2016

0 Stimmen

2 Kommentare

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 am 29 Feb. 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Guillaume
Guillaume am 28 Feb. 2016

0 Stimmen

"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 Kommentare

rayjoe
rayjoe am 28 Feb. 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.
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Feb. 2016

Kommentiert:

am 29 Feb. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by