[求助]S函数中能否调用M函数
我现在写了一个S-FUNCTION
里面调用了一些M函数,当把S函数的名字写入S—FUNCTION块的时候
总是出现
??? SWITCH expression must be a scalar or string constant.
Error in ==> HSV at 32
switch flag,
不知道该如何处理了,请教大家了
AreaCXJTFT等都为M函数,如果我调用方式出现错误,请指出阿,:biggrin: :biggrin:
程序如下:
看着很麻烦,其实就是判断区域Area后,根据Area的值选择输出的计算方式:
function [sys,x0,str,ts]=HSV(t,x,u,flag)
switch flag,
case 0
[sys,x0,str,ts] = mdlInitializeSizes; % Initialization
case 3
sys = mdlOutputs(t,x,u); % Calculate outputs
case { 1, 2, 4, 9 }
sys = []; % Unused flags
otherwise
error(['Unhandled flag = ',num2str(flag)]); % Error handling
end;