%for every input the function gives int8 as an output
function x=integerize(A)[m,n]=size(A);for ii=1:m for jj=1:n if isa(A(ii,jj),'double') b=min(A); if -128 <= b <= ((2^7)-1) x='int8'; elseif (-2^15)<= b <= ((2^15)-1) x='int16'; elseif (-2^31)<=b<= ((-2^31)-1) x='int32'; elseif (-2^63)<=b<=((2^63)-1) x='int64'; else x='NONE'; end else x='NONE'; end end end
MATLAB: Write a function called integerize that takes as its input a matrix A of integers of type double, and returns the name of the “smallest” signed integer class to which A can be converted without loss of information. If no such class exists, the text
homeworkintegerize
Best Answer