Programmatically change MATLAB Fcn Block Function Configuration Script
Ältere Kommentare anzeigen
I'm hoping to programmatically change the Function Script for a MATLAB Fcn Block
currentScript = 'function y = fcn(u, value)';
config = get_param(mFcnBlock, 'MATLABFunctionConfiguration');
config.FunctionScript = currentScript;
My code is as shown above, and this works as intended. The result is:
function y = fcn(u, value)
How would I change the currentScript to be the following?
function y = fcn(u, value)
switch u
case true
y = value;
case false
y = 0;
otherwise
y = nan;
end
I've tried several ways, but the function script almost always ends up as the following:
function y = fcn(u, value,switch,ucase,truey, value1,case,false,y, otherwise, y1, nan,end)
Thanks!
Akzeptierte Antwort
Weitere Antworten (1)
Aaryan
am 9 Mai 2023
0 Stimmen
how to add a new function to the same block?
like function x = fcn(u,v)
Kategorien
Mehr zu Interactive Model Editing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!