Why is it Showing this error?
显示 更早的评论
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 string 'NONE' is returned. For example, if the smallest element of A is -100 and the largest is +100, then the function would return 'int8'. As another example, if there is an element of A equal to -1e20, then the function would return 'NONE'.
if true
% code
end
function s=integerize(A)
if (A<=127 && A>=-128)
s='int8';
else if(A<=32767 && A>=-32768)
s='int16';
else if (A<=2147483647 && A>=-2147483648)
s='int32';
else if (A<9223372036854775807 && A>-9223372036854775808)
s='int64';
else
s='NONE';
end;
* _Error: File: integerize.m Line: 6 Column: 10
At least one END is missing: the statement may begin here._*
1 个评论
David William Armstrong
2017-10-11
You need to end both the function and the if/else statement.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!