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.

 채택된 답변

Walter Roberson
Walter Roberson 2016년 2월 28일

0 개 추천

댓글 수: 2

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.
Guillaume and Walter, thanks for all the suggestions. They give me enough ideas and directions to digest and start with where to go. -raymond

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Guillaume
Guillaume 2016년 2월 28일

0 개 추천

"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

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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2016년 2월 28일

댓글:

2016년 2월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by