필터 지우기
필터 지우기

Vector range error in matlab

조회 수: 1 (최근 30일)
Valters
Valters 2022년 12월 14일
댓글: Bora Eryilmaz 2022년 12월 14일
I have this problem when I write range of vector, maybe someone can help me! Incorrect number or types of inputs or outputs for function 'range'.
Error in Matlabdarbs2 (line 67)
range(o);
There is my code - o=[2, 4, -3, 0, 1, 5, 7];
range(o);
mean(o);
median (o);

답변 (1개)

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 14일
편집: Bora Eryilmaz 2022년 12월 14일
Works just fine for me:
o = [2, 4, -3, 0, 1, 5, 7];
range(o)
ans = 10
mean(o)
ans = 2.2857
median(o)
ans = 2
You can do
which -all range
/MATLAB/toolbox/stats/stats/range.m /MATLAB/toolbox/shared/channel/rfprop/@txsite/range.m % txsite method /MATLAB/toolbox/stats/distributed/@distributed/range.m % distributed method
to see which range function is being called. The one that I get is the one from the Statistics Toolbox.
  댓글 수: 3
Steven Lord
Steven Lord 2022년 12월 14일
Yes, the range function for numeric arrays is part of Statistics and Machine Learning Toolbox.
An alternative if you don't have this toolbox available is to call bounds (which is part of MATLAB) and calculate the range from its two outputs.
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 14일
For vectors, computing the range is pretty simple. You can do it yourself without needing a command.
o = [2, 4, -3, 0, 1, 5, 7];
range = max(o) - min(o)
range = 10

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

카테고리

Help CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by