Vector range error in matlab
1 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
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)
mean(o)
median(o)
You can do
which -all range
to see which range function is being called. The one that I get is the one from the Statistics Toolbox.
3 个评论
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
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)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!