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

조회 수: 16 (최근 30일)
Andy
Andy 2022년 9월 20일
편집: Fangjun Jiang 2022년 9월 30일
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
Walter Roberson
Walter Roberson 2022년 9월 29일
Hmmm, I have no explanation at this time.
Fangjun Jiang
Fangjun Jiang 2022년 9월 30일
편집: Fangjun Jiang 2022년 9월 30일
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.

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

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2022년 9월 20일
편집: Fangjun Jiang 2022년 9월 20일
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
Walter Roberson
Walter Roberson 2022년 9월 20일
@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 2022년 9월 20일
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.

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

카테고리

Help CenterFile Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by