利用 Switch block
利用 Matlab Function block
function [mean, stdev] = fcn(vals)
% #codegen
% calculates a statistical mean and a standard
% deviation for the values in vals
len = length(vals);
mean = avg(vals, len);
stdev = mean+1;
coder.extrinsic('plot');
plot(vals, '-+');
function mean = avg(array, size)
mean = sum(array)/size;