Why I recive such an answer:"Incorrect number or types of inputs or outputs for function range."
256 views (last 30 days)
Show older comments
I wrote the following codes:
x = [1 -1.65 2.2 -3.1];
y = range(x)
But MATLAB's answer is "Incorrect number or types of inputs or outputs for function range."
Did I made any mistake?
3 Comments
Accepted Answer
DGM
on 28 Dec 2023
Moved: DGM
on 28 Dec 2023
x = [1 -1.65 2.2 -3.1];
y = range(x)
The code you posted should work fine. You probably have something shadowing the intended file.
Check the output of
which range -all
If you see some user-created function file in that list, rename it to something other than range.m. Likewise, if this error is happening in some a script or function with a local function called range(), fix that.
6 Comments
DGM
on 29 Dec 2023
If you want, here's a replacement for range() (attached)
% test row vector
args = {rand(1,100)};
x1 = range(args{:});
x2 = myrange(args{:});
isequal(x1,x2)
% test col vector
args = {rand(100,1)};
x1 = range(args{:});
x2 = myrange(args{:});
isequal(x1,x2)
% test with specified dimension
args = {rand(100),2};
x1 = range(args{:});
x2 = myrange(args{:});
isequal(x1,x2)
I'm just recalling the behavior off the top of my head, but the original implementation should be similar, if not a bit simpler. There's not much to it.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!