Why this error with `axis`

6 ビュー (過去 30 日間)
Pankaj
Pankaj 2018 年 10 月 9 日
編集済み: Stephen23 2018 年 10 月 9 日
>> axis('limits',[0 60 0 50 0.13 0.23],'style', 'square')
The above produces following error error-
Error using axis (line 2)
Unknown command option limits.
where as following does not
axis([0 60 0 50 0.13 0.23], 'square')
From here limits and style, both are legitimate properties.

回答 (2 件)

Star Strider
Star Strider 2018 年 10 月 9 日
‘... limits and style, both are legitimate properties’
They are. However you have to call them separately:
figure
surf( ... )
axis([0 60 0 50 0.13 0.23])
axis('square')
  5 件のコメント
Pankaj
Pankaj 2018 年 10 月 9 日
May be I would. Anyways, thanks @strider.
Star Strider
Star Strider 2018 年 10 月 9 日
My pleasure.
Note that I was addressing the name-value pair argument issue, not combining multiple commands in one axis call, that I have also done successfully in the past.

サインインしてコメントする。


Stephen23
Stephen23 2018 年 10 月 9 日
編集済み: Stephen23 2018 年 10 月 9 日
The actual answer is that you can combine multiple inputs, but that those inputs are not name-value inputs (like many other MATLAB functions use): for axis you only need the values by themselves:
axis([0,60,0,50,0.13,0.23],'square')
The reason names are not required is because none of the inputs are ambiguous, what their purposes are. It is worth noting that some other functions also use this method of supplying multiple input arguments, in particular regexp, regexpi, regexprep, where the input arguments are unambiguous in any order. The functions which and load also allow (at least some of) their options to be given in different orders, although this is not documented. There might be other functions...
Nowhere in the axis help does it mention using names, as you are doing.
However the axis help does clearly state that you can use multiple inputs: "You can combine multiple input arguments together, for example, axis image ij. The options are evaluated from left to right. Subsequent options can overwrite properties set by prior ones."
  2 件のコメント
Pankaj
Pankaj 2018 年 10 月 9 日
I know that combine multiple inputs but we are habitual of using key-values and most of the functions do use key-values. And that is the source of my confusion, why MathWorks has designed this function in peculiar way.
Stephen23
Stephen23 2018 年 10 月 9 日
編集済み: Stephen23 2018 年 10 月 9 日
"why MathWorks has designed this function in peculiar way."
For the "convenience", I suspect. But if you want to know why, you would have to ask its author.
As I noted in my answer, other MATLAB functions also use this input method, as values without names (in particular the regexp family of functions).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by