tan function giving an error
1 回表示 (過去 30 日間)
古いコメントを表示
x = (-pi/2)+0.01:0.01:(pi/2)-0.01; plot(x,tan(x)), grid on
gives an error: Array indices must be positive integers or logical values. but changing tan to either sin or cos does not give an error. Code above is from MATLAB.
0 件のコメント
採用された回答
Star Strider
2018 年 10 月 28 日
Your code works when I run it.
That you are getting the error: ‘Array indices must be positive integers or logical values.’ leads me to believe that you have a variable named ‘tan’ in your workspace. This is called ‘overshadowing’ a function.
To find out, run this from your Command Window or a script:
which tan -all
If the first result is:
tan is a variable.
You have found the problem. You then have to rename the ‘tan’ variable to something meaningful, and so the name does not ‘overshadow’ any MATLAB functions.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!