function [lgc,in1data,in2data] = compadata(inportdata_1,inportdata_2)
if iscell(inportdata_1)
inportdata_1=inp
ortdata_1{:};
end
if iscell(inportdata_2)
inportdata_2=inportdata_2{:};
end
%%输入口1
in1obj = evalin('base',['whos(''',inportdata_1,''');']);
if ~isempty(in1obj)
switch in1obj.class
case 'Simulink.AliasType'
in1data = evalin("base",[inportdata_1,'.BaseType;']);
case 'Simulink.NumericType'
temstr = evalin("base",[inportdata_1,';']);
switch temstr.DataTypeMode
case 'Fixed-point: slope and bias scaling'
in1data='';
if strcmp(temstr.Signedness,'Signed')
in1data = 'sfix';
elseif strcmp(temstr.Signedness,'Unsigned')
in1data = 'ufix';
end
if temstr.Slope == 1
if contains(in1data,'sfix')
in1data=['int',num2str(temstr.WordLength)];
elseif contains(in1data,'ufix')
in1data=['uint',num2str(temstr.WordLength)];
end
else
if rem(log2(temstr.Slope),1) == 0
in1data = [in1data,num2str(temstr.WordLength),'_En',num2str(abs(round(log2(temstr.Slope))))];
else
in1data = [in1data,num2str(temstr.WordLength),'_Sp',strrep(num2str(temstr.Slope),'0.','')];
end
if temstr.Bias ~=0
in1data = [in1data,'_B',num2str(temstr.Bias)];
end
end
case 'Fixed-point: unspecified scaling'
in1data='';
if strcmp(temstr.Signedness,'Signed')
in1data = 'sfix';
in1data = [in1data,num2str(temstr.WordLength),'_En',num2str(temstr.WordLength-2)];
elseif strcmp(temstr.Signedness,'Unsigned')
in1data = 'ufix';
in1data = [in1data,num2str(temstr.WordLength),'_En',num2str(temstr.WordLength-1)];
end
case 'Fixed-point: binary point scaling'
in1data='';
if strcmp(temstr.Signedness,'Signed')
in1data = 'sfix';
elseif strcmp(temstr.Signedness,'Unsigned')
in1data = 'ufix';
end
if temstr.FractionLength ~= 0
in1data = [in1data,num2str(temstr.WordLength),'_En',num2str(temstr.FractionLength)];
else
if contains(in1data,'sfix')
in1data=['int',num2str(temstr.WordLength)];
elseif contains(in1data,'ufix')
in1data=['uint',num2str(temstr.WordLength)];
end
end
end
end
else
if ~isempty(Simulink.findIntEnumType(inportdata_1))
in1data = Simulink.data.getEnumTypeInfo(inportdata_1,'StorageType');
else
in1data = inportdata_1;
end
end
This is an example I wrote, later you can use for reference.