f



Can't use 'sum function'

noise = [1,2,0,3,0,0,0,4];
a = sum(noise)

when I execute this I get:

??? Subscript indices must either be real positive integers or logicals.

Error in ==> test3>haps at 22
  a = sum(noise)

Error in ==> test3 at 5
C    = haps(2);

>>

what is wrong??

JOhs 


0
sdfs (14)
6/18/2006 5:20:16 PM
comp.soft-sys.matlab 211266 articles. 17 followers. lunamoonmoon (258) is leader. Post Follow

3 Replies
563 Views

Similar Articles

[PageSpeed] 31

On Sun, 18 Jun 2006 19:20:16 +0200, Johs32 wrote:

> noise = [1,2,0,3,0,0,0,4];
> a = sum(noise)
> 
> when I execute this I get:
> 
> ??? Subscript indices must either be real positive integers or logicals.
> 
> Error in ==> test3>haps at 22
>   a = sum(noise)
> 
> Error in ==> test3 at 5
> C    = haps(2);
> 
>>>
> 
> what is wrong??
> 
> JOhs

You have a variable called 'sum' in your workspace.  Try renaming it to
something else in your script or clear it before doing the sum.

Dan


0
dan4519 (925)
6/18/2006 5:56:59 PM
Johs32 wrote:
> noise = [1,2,0,3,0,0,0,4];
> a = sum(noise)
> 
> when I execute this I get:
> 
> ??? Subscript indices must either be real positive integers or logicals.
> 
> Error in ==> test3>haps at 22
>   a = sum(noise)
> 
> Error in ==> test3 at 5
> C    = haps(2);
> 
> 
> what is wrong??
> 
> JOhs 
> 
> 


at the place where this happens, set a breakpoint, start the program and 
once the debugger stops there, at the commandline type "which sum" and 
report the findings.
i suspect you defined a local SUM function which shadows the one defined 
in matlab...

michael
0
mwild (177)
6/18/2006 6:03:38 PM
Michael Wild wrote:
>
>
> Johs32 wrote:
>> noise = [1,2,0,3,0,0,0,4];
>> a = sum(noise)
>>
>> when I execute this I get:
>>
>> ??? Subscript indices must either be real positive integers or
> logicals.
>>
>> Error in ==> test3>haps at 22
>> a = sum(noise)
>>
>> Error in ==> test3 at 5
>> C = haps(2);
>>
>>
>> what is wrong??
>>
>> JOhs
>>
>>
>
>
> at the place where this happens, set a breakpoint, start the
> program and
> once the debugger stops there, at the commandline type "which sum"
> and
> report the findings.
> i suspect you defined a local SUM function which shadows the one
> defined
> in matlab...
>
> michael
>
  
Actually, this should be a variable named sum.
Note the error message. It refers to the line

>> a = sum(noise)

and then talks about subscript indices.

Never name things names like sum.

John
0
woodchips (7942)
6/18/2006 7:04:01 PM
Reply: