uint32 function example produces the "Index exceeds the number of array elements (1)" error

When running the Convert to 32-Bit Unsigned Integer Variable.mlx example in Matlab it produces the "Index exceeds the number of array elements (1)". It does not produce the Matworks resut. Why?

3 Comments

dunno w/o seeing exactly what you did and error message in context...don't even know what example that would be.
[Gilles Answer moved to comment--dpb]
Just type uint32 in R2019 Documentation Search
and read throug and execute example.
or here
Still dunno w/o seeing further details...works here.
Cut 'n paste commands to command line and I'll be extremely surprised if it doesn't work.
I've never used those pretty features; quite possible there's a typo in there or something I suppose.

Sign in to comment.

 Accepted Answer

When you execute a Live Script (.slx) then except for parts within a "function", it is a script like non-live scripts, which is to say that it executes within the context of the workspace of the caller ... inheriting whatever assignments have already been done.
So, the difficulty you are encountering is that in your base workspace, you have a variable named class or a variable named uint32 so when you execute the example code, referring to class(x) or uint32(x) would be a subscript request rather than a function call.

More Answers (0)

Products

Release

R2019a

Community Treasure Hunt

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

Start Hunting!