MATLAB code that reads in an logic code input file
Show older comments
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.
Accepted Answer
More Answers (1)
Guillaume
on 28 Feb 2016
0 votes
"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 Comments
rayjoe
on 28 Feb 2016
Guillaume
on 28 Feb 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.
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!