How to robustly parse string into output arguments, function handle and input arguments
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jori Selen
am 11 Jun. 2021
Kommentiert: Stephen23
am 11 Jun. 2021
In a textbox in a GUI, a user can enter a function that they wish to execute. For example,
[ out1, out2 ] = name_of_a_function(in1, in2, in3);
When submitted, this is communicated to the backend as the string
"[ out1, out2 ] = name_of_a_function(in1, in2, in3);"
Is there a robust way to decompose this string into the names of output arguments, function handle and input arguments taking into account that users can use any valid Matlab syntax and any number of output and input arguments, perhaps providing input arguments directly as vectors, matrices or cell arrays instead of using variable names?
1 Kommentar
Stephen23
am 11 Jun. 2021
"Is there a robust way to decompose this string..."
Not really. Read this discussion, including all of the comments:
Akzeptierte Antwort
Chunru
am 11 Jun. 2021
It will be a challenging task. Hope the following can help
t =mtree('[ out1, out2 ] = name_of_a_function(in1, in2, in3);')
dumptree(t)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!