CVX does not work in m file

Uncategorized
Feb 23, 2022
M

Hello to everyone

I downloaded CVX on 23 Feb. I want to test the CVX for the first time and compare it with Linprog.
I wrote my code in Matlab command and I got results with CVX. However, I tried to save my code in mfile to run it. But, my code does not work in mfile!
I am so thankful if you let me CVX has a problem with the mfile of the MATLAB or not.
This is my code:

clear
clc
A=[1 -1 1;3 2 4; 3 2 0];
b=[20;42;30];
lb=zeros(3,1);
f=[-5,-4,-6];
cvx_begin
variable x(3)
minimize (fx)
subject to
lb <= A
x <= b
cvx_end

M

That should work if the m file is in your MATLAB path or the directory from which you are running MATLAB.

What happens when you try to run the m file? Is it a script? In what sense, exactly< does the code not work using m file?

M

Hello

I clicked on RUN and I clicked on Add to path or Change.
image

But, the problem is after RUN the mfile there is no result in MATLAB command

M

This is the result in the MATLAB command
res

M

My problem is solved.
In fact, the name of my mfile was “linear”, which cause problems for MATLAB.
I changed it and it worked