1.相关的.m函数代码为:
function [lsh3, rsh2] = xlsimpleshift(din)
% [lsh3, rsh2] = xlsimpleshift(din) does a left shift 3 bits and a
% right shift 2 bits. The shift operation is accomplished by
% multiplication and division of power of two constant.
lsh3 = din * 8;
rsh2 = din / 4;
2.将.m函数添加到下列三个位置之一:
• 模型文件存放的位置;
• 模型目录下名字为private的子文件夹;
• MATLAB路径下。
然后,新建一个System Generator设计,添加MCode模块,双击模块,在弹出页面中,通过Browse按键将.m函数和模型设计关联起来,如图7-18所示。