how define input data type
14 ビュー (過去 30 日間)
古いコメントを表示
when defining a function, for example
function y = func(x)
how can I define that x is of a specific type, like uint8?
0 件のコメント
採用された回答
その他の回答 (2 件)
Jan
2011 年 3 月 31 日
I do not see the problem.
function y = func(x)
disp(x + x)
And then call it with an UINT8:
func(uint8(1:10))
Or do you want to reject inputs with a deviating type? Then:
function y = func(x)
if ~isa(x, 'uint8')
error('Bad type!');
end
disp(x + x)
Or do you want to convert the input?
function y = func(x)
x = uint8(x);
disp(x + x)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で MATLAB Code Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!