clear close all N=100; t=1:N; x=linspace(0,100,N); y=single(x); z=half(x); yType=DataType2Idx(y); out=sim('simdatatypes.slx'); dat=out.yout{1}.Values; subplot(211) plot(t,x-y); hold on plot(dat.Data(:,1),dat.Data(:,2),'x'); legend('Matlab','PLECS/Simulink'); subplot(212) plot(t,x-z); hold on plot(dat.Data(:,1),dat.Data(:,3),'x'); legend('Matlab','PLECS/Simulink'); function idx = DataType2Idx(data) Types = {'bool','uint8','int8','uint16','int16','uint32','int32','single','double'}; idx = find(strcmp(Types, class(data))); if isempty(idx) error('PLECS does not support conversion to this datatype'); end end