필터 지우기
필터 지우기

Get max, min and precision of a fi

조회 수: 19 (최근 30일)
Justin
Justin 2019년 3월 27일
편집: Harry 2021년 7월 30일
What is the easiest way to find the maximum or minimum value that a fi can take?
What is the easiest way to find the precision of a fi?

채택된 답변

Jan
Jan 2019년 3월 27일
편집: Jan 2019년 3월 28일
a = fi(pi, true, 16, 12);
xi = intmax(a)
This is code taken from https://www.mathworks.com/help/fixedpoint/ref/intmax.html , which I found as first link by asking an internet search engine for "Matlab fi maximum value".
a = fi(pi, true, 16, 12);
xd = realmax(a)
  댓글 수: 3
Jan
Jan 2019년 3월 28일
I cannot test this, because I do not have the FI toolbox. But what about realmax?
Justin
Justin 2019년 3월 28일
Yes, that looks good. found everything I need here:https://uk.mathworks.com/help/fixedpoint/data-type-operators-and-tools.html
upperbound and lowerbound (or range) and realmin get me what I want. Thanks for your help navigating the documentation!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Justin
Justin 2019년 3월 27일
I have answered my own question by creating the following function:
function info = fiInfo(inFi)
if inFi.Signed
info.max = (2^(inFi.WordLength - 1) - 1) / 2^inFi.FractionLength;
info.min = -2^((inFi.WordLength - 1) - inFi.FractionLength);
info.precision = 2^-inFi.FractionLength;
else
info.max = (2^inFi.WordLength - 1) / 2^inFi.FractionLength;
info.min = 0;
info.precision = 2^-inFi.FractionLength;
end
end
resulting in
>> a = fi(pi, true, 16, 12);
>> fiInfo(a)
ans =
struct with fields:
max: 7.9998
min: -8
precision: 2.4414e-04
or
>> a = fi(pi, false, 16, 12);
>> fiInfo(a)
ans =
struct with fields:
max: 15.9998
min: 0
precision: 2.4414e-04
This seems to be a lot of faffing to get at some basic info. Surely there is a better way?

Harry
Harry 2021년 7월 30일
편집: Harry 2021년 7월 30일
% A fixed-point object with no value, 18-bit word length, and 16-bit fraction length
a = fi([],1,18, 16)
a = [] DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 18 FractionLength: 16
% The easiest way to find the maximum or minimum value that a fi can represent is
range(a)
ans =
-2.0000 2.0000 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 18 FractionLength: 16
% The easiest way to find the precision of a fi is
eps(a)
ans =
1.5259e-05 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 18 FractionLength: 16

카테고리

Help CenterFile Exchange에서 Fixed-Point Designer에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by