Clear Filters
Clear Filters

Why do I get "Array indices must be positive integers or logical values" error when using "angle" function?

9 views (last 30 days)
Hey guys, does anyone know whats wrong.
I already have my line code working. But once I run it on appdesigner.
It display "Array indices must be positive integers or logical values".
Can you guys help me pls

Answers (2)

Fifteen12
Fifteen12 on 2 Dec 2022
Without seeing your code it's impossible to answer your question, but try outputing all your variables to the terminal, it's easy to have a mistake. To make it easier, try debugging your script by placing a breakpoint early in your code and stepping through it. You can check each variable as you go, it's probably an honest mistake.

Star Strider
Star Strider on 2 Dec 2022
You have a variable named ‘angle’ somewhere in your workspace. If you run:
which angle -all
/MATLAB/toolbox/matlab/elfun/angle.m /MATLAB/toolbox/ident/ident/@iddata/angle.m % iddata method /MATLAB/toolbox/nnet/deep/@dlarray/angle.m % dlarray method /MATLAB/toolbox/parallel/gpu/@gpuArray/angle.m % gpuArray method /MATLAB/toolbox/parallel/parallel/@codistributed/angle.m % codistributed method /MATLAB/toolbox/symbolic/symbolic/@sym/angle.m % sym method
the results should be similar to these.
If you have a variable called ‘angle’
angle = pi;
which angle -all
angle is a variable. /MATLAB/toolbox/ident/ident/@iddata/angle.m % Shadowed iddata method /MATLAB/toolbox/nnet/deep/@dlarray/angle.m % Shadowed dlarray method /MATLAB/toolbox/parallel/gpu/@gpuArray/angle.m % Shadowed gpuArray method /MATLAB/toolbox/parallel/parallel/@codistributed/angle.m % Shadowed codistributed method /MATLAB/toolbox/symbolic/symbolic/@sym/angle.m % Shadowed sym method /MATLAB/toolbox/matlab/elfun/angle.m % Shadowed
the results should demonstrate that as well.
The solution is to rename the variable to something that does not overshadow any MATLAB function.
.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!