tan function giving an error
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Richard O'Sullivan
il 28 Ott 2018
Risposto: Star Strider
il 28 Ott 2018
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 Commenti
Risposta accettata
Star Strider
il 28 Ott 2018
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!