I have two file on matlab: lab1.m and funct.m where lab1.m is main program and funct.m is function y = a*x-b.

To solve on funct.m, I use lab1.c program

I write:

cvx_begin

variable x(4)

expression y

y = funct(x)

minimize (norm (y))

cvx_end

But,I saw error:

Error using cvx/subsref (line 13)

Function ‘subsindex’ is not defined for values of class ‘cvx’.

Error in lab1 (line 18)

y = a(x)

Please help me !

It looks like you are attempting to index an array with a CVX variable. I’m afraid you simply can’t do that with a CVX variable—it does not satisfy the disciplined convex programming ruleset. CVX models must employ only those functions found in the function reference and combined according to those rules. All other models are rejected. CVX is probably not going to work fro your application.

Thanks mcg!

Can you fix for me! I don’t know how to do. Please hlep me!

No, I cannot, because you haven’t made it clear what you’re trying to do. If your model is not convex, CVX simply cannot solve it. And CVX cannot use external functions written in C as you seem to be trying to do.