How do I tell Matlab to use the proper "range" function?

19 views (last 30 days)
I have a script that I wrote a while ago that started misbehaving after I installed the Antenna Toolbox. This script uses the "range" function to find the largest delta between min and max values in the first column:
myrange = range(myarray,1);
I got an error and then checked the help on this function and found that it's coming from a radio propagation function in that toolbox.
which range
C:\Program Files\MATLAB\R2022a\toolbox\shared\channel\rfprop\@txsite\range.m
How do I get Matlab to use the basic "range" function in my script?
Also, as a followup, I ran:
which range -all
and it only shows the function in that rfprop toolbox. So I don't even know where the original "range" function is supposed to be.
  14 Comments
Fangjun Jiang
Fangjun Jiang on 30 Sep 2022
Edited: Fangjun Jiang on 30 Sep 2022
I noticed this befroe but didn't bring it up. My take is this:
"which -all range" shows all the range.m files in the path. It also shows the range.m files inside a class, which is surprised to me. For example
\toolbox\stats\stats\range.m
\toolbox\fixedpoint\fixedpoint\@embedded\@numerictype\range.m % embedded.numerictype method
\toolbox\mbc\mbcmodels\@xregexportmodel\range.m % xregexportmodel method
\toolbox\mbc\mbcmodels\@xregmodel\range.m % xregmodel method
\toolbox\mbc\mbctools\@sweepset\range.m % sweepset method
\toolbox\shared\channel\rfprop\@txsite\range.m % txsite method
\toolbox\stats\distributed\@distributed\range.m
"which range(1:4)" tries to find a range.m that fits the input argument. If you remove \toolbox\stats\stats from the path, then it won't find any range.m that fits it. So the " 'range(1:4)' not found" message makes sense.
After removing \toolbox\stats\stats from the path, if you run range(1:4), I got the error message in R2022b
"Incorrect number or types of inputs or outputs for function 'range'"
My guess is that it didn't find the right fit, so it ran the first range.m and gave error message regarding incorrect number or types, because it didn't know whether the user didn't intend to use this range.m, or, the user intended to use this range.m but made mistake providing inputs.
In summary:
"which range(1:4)", it can afford to tell you that there is no matching range.m
"range(1:4)", It can't affort to tell you that range.m does not exist. It tells you that range.m does exist, but there is an error running it.
Of course, all this can be changed. It is up to the Mathworks how to present the message.

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 20 Sep 2022
Edited: Fangjun Jiang on 20 Sep 2022
Run "which -all range".
The first one is used. The rests are shadowed, or private which will not affect you.
The 'the basic "range" function' comes from this toolbox. Make sure you have it.
\toolbox\stats\stats\range.m
  7 Comments
Walter Roberson
Walter Roberson on 20 Sep 2022
@txsite\range.m can only get called for objects of class txsite, unless range happens to be defined as a static method of class txsite.
Andy
Andy on 20 Sep 2022
I don't know how to use classes or methods. I was just performing some simple plotting of basic 2 dimensional numeric arrays that I had stored from some previous measurements.

Sign in to comment.

Categories

Find more on Propagation and Channel Models in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!