ECE
ECE

Reputation: 414

Take the difference of 2 vectors and sum and square them

I have 2 vectors of size 1x90.

I have to do the operator

diff=sum((V_new-V).^2);

But every time i do it i get the error:

Subscript indices must either be real positive integers or logical.

How can i fix this problem and prevent it from occurring again?

Upvotes: 1

Views: 2700

Answers (1)

Shai
Shai

Reputation: 114816

make sure you did not step over the sum function:

  1. type

    >> dbstop if error
    
  2. run the code, it should stop in debugger when error occurred.

  3. check what sum is:

    >> which sum
    

    should return that sum is a build-in function, but if you accidentally created a variable with that name, it will tell you that sum is a variable.

DO NOT USE BUILT-IN FUNCTIONS' NAMES AS VARIABLES

Upvotes: 3

Related Questions