Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Please help: Error- "Colon operands must be in range of the data type"

117 views
Skip to first unread message

Ramita S.

unread,
Jan 15, 2010, 2:25:06 AM1/15/10
to
Hello,

I'm hoping somebody with MATLAB expertise could tell me what the following error message mean and/or how to avoid it.

"??? Colon operands must be in range of the data type."

It occurs at the line:
82: on_ind(z) = find( U_GK(off_ind(z-1):end)>=7 ,1,'first') + off_ind(z-1)-1;

where
U_GK(off_ind(z-1):end)
when singled out seems to be the crux of the problem, with

U_GK [85000x1 double]
off_ind [1x1 uint16] in this iteration
z [1x1 unint16] = 2 in this iteration

What stumps me is that the whole line 82 was copied directly from another function I've worked on, which runs fine with no warning/error in another set of input data with similar Workspace and structure (though U_GK dimension is [8500x1])

Moreover, I've tried the following steps in Command Window in debug mode:

K>> z
ans =
2

K>> off_ind(z-1)
ans =
6011

K>> U_GK(off_ind(z-1))
ans =
5.4571

K>> U_GK(end)
ans =
0.0078

K>> U_GK(6011:end)
ans =
[78990x1 double with 5.4571 as the first element and 0.0078 as the last]

Setting an intermediate variable for off_ind or using eval() didn't solve the problem either.

My coding is definitely far from efficient or elegant, so I'd be grateful for any advice to improve and/or eliminate the error.

Thank you in advance :)

Ramita

Rune Allnor

unread,
Jan 15, 2010, 3:47:52 AM1/15/10
to
On 15 Jan, 08:25, "Ramita S." <rsuteek...@gmail.com> wrote:
> Hello,
>
> I'm hoping somebody with MATLAB expertise could tell me what the following error message mean and/or how to avoid it.
>
> "??? Colon operands must be in range of the data type."

> z               [1x1 unint16] = 2 in this iteration

The problem is that you are using data of type UINT16.

A 16-bit integer can only represent 2^16 = 65536 different
numbers. If you want to represent larger integer values,
you will have to use some other data type.

Rune

Ramita S.

unread,
Jan 15, 2010, 4:49:02 AM1/15/10
to
Thank you very much. That solves the problem.
From your help off_ind is now changed to [nx1] uint32 :)

- Ramita

Rune Allnor <all...@tele.ntnu.no> wrote in message <48f8f18f-750f-4a82...@c34g2000yqn.googlegroups.com>...

0 new messages