Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
codegen - mxarray indices are not supported

Subject: codegen - mxarray indices are not supported

From: Chuck37

Date: 23 Aug, 2011 19:01:25

Message: 1 of 2

I have some pretty simple seeming code, like this:

n = length(vec);
ord = bitrevorder(1:n);
vec = vec(ord);

It just puts e vector in bit reverse order.

Now I'm trying to convert to a MEX file using codegen and running into all sorts of trouble. First, of course, is that bitrevorder is not supported. But ignoring that, I keep getting errors about "mxarray indices are not supported". This seems to be preventing me from doing the most basic things. It's griping about the "vec = vec(ord)" line. I cannot believe that the coder won't support indexing into vectors, what am I missing?

Even writing it out like this breaks:

vec2 = vec;
for k = 1:n
  vec(k) = vec2(ord(k));
end

There must be a way to reorder a vector according to a list of indices. Any help would be greatly appreciated!

Subject: codegen - mxarray indices are not supported

From: Chuck37

Date: 23 Aug, 2011 20:16:13

Message: 2 of 2

"Chuck37" wrote in message <j30te5$bem$1@newscl01ah.mathworks.com>...
> I have some pretty simple seeming code, like this:
>
> n = length(vec);
> ord = bitrevorder(1:n);
> vec = vec(ord);
>
> It just puts e vector in bit reverse order.
>
> Now I'm trying to convert to a MEX file using codegen and running into all sorts of trouble. First, of course, is that bitrevorder is not supported. But ignoring that, I keep getting errors about "mxarray indices are not supported". This seems to be preventing me from doing the most basic things. It's griping about the "vec = vec(ord)" line. I cannot believe that the coder won't support indexing into vectors, what am I missing?
>
> Even writing it out like this breaks:
>
> vec2 = vec;
> for k = 1:n
> vec(k) = vec2(ord(k));
> end
>
> There must be a way to reorder a vector according to a list of indices. Any help would be greatly appreciated!

I figured out this may have to do with the fact that I used coder.extrinsic on bitrevorder. Looks like I have to declare the output variable before the call.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us