Hi Antonio,
I understand that you are looking for a way to incorporate user-entered code into your function for decision-making purposes.
To do this, you can use the “eval” function in MATLAB. The “eval” function allows you to execute MATLAB code that is provided as a string. By passing the text entered by the user from the GUI as input to the “eval” function, you can execute the code within your function.
Here is an example of how you can use the “eval” function:
% Assume userCode is the string containing the user-entered code
userCode = 'disp("Hello, world!");';
% Use eval to execute the user's code
eval(userCode);
In this example, the “userCode” variable holds the code entered by the user as a string. By using “eval”, the code is executed, and the output, in this case, would be the display of "Hello, world!".
However, it is important to note that using “eval” with user-entered code can be risky, as it can introduce security vulnerabilities and make your code harder to debug. It is generally recommended to use “eval” with caution and validate any user-provided input or code to ensure its safety and reliability.
For more information on the “eval” function, please refer to the following MATLAB documentation: https://www.mathworks.com/help/matlab/ref/eval.html
Additionally, the below documentation also provides alternatives to using “eval”, which you may find helpful: https://www.mathworks.com/help/matlab/matlab_prog/string-evaluation.html
Hope this Helps!