Total Variation (TV) Norm Function Input: Vector or Matrix?

I am trying to use the CVX toolbox with my own TV norm Matlab function. I know that the TV norm is also known as the “discrete TV seminorm” and that it meets the first three properties of a vector norm; therefore it is convex because all norms are convex. My Matlab function’s input is a matrix (namely, an image); however, from reading CVX the manual it appears that the CVX toolbox works better with vectors; so, can I modify my TV norm function’s inputs to be a vector, number or rows (m) and columns (n), then inside my function convert the vector to an mxn matrix, and then return as the output of my TV norm function, the TV norm of this matrix (image) created from the vector inside my function? I will appreciate any assistance.

I see no reason why you can’t use matrix expressions. You’ll need to offer more specifics about exactly what function you’re trying to build. But it seems to me that this is a reasonable implementation of a certain form of the TV function:


This is my version:



tvnorm=sum(sqrt(v1.^2 + v2.^2));

However, I get a totally different number as when I use your version:


…or I am probably doing something wrong…?

Is the “norm” function that you use in your example the same as the norm function in Matlab or is this “norm” function a different function only used within CVX commands?

Well yes, this actually should not work at all in CVX, as it violates the disciplined convex programming ruleset.