Why I am getting this error message? How to fix it?

17 次查看(过去 30 天)
Undefined function 'vec' for input arguments of type 'double'.
Error in cvx/quad_form (line 43)
v = vec( v );
Error in algorithm_BCD>update_theta (line 85)
term1 = quad_form(hk, W*W');

回答(1 个)

Torsten
Torsten 2024-4-16,11:38
编辑:Torsten 2024-4-16,11:39
Maybe you mean this function:
function v = vec(m)
%Helper function to turn a matrix of any size into a column vector using (:)
% This function is meant to make one-line computations easy/fast when
% subscripting already.
%SCd 01/04/2011 (First function of 2011!)
%
%Updates: -05/24/2011: Used reshape instead of colon for speed.
%
%Usage: v = vec(m)
%
%Example:
% %Original way to one line the median of a slice of 3d matrix:
% M = repmat(magic(200),[1 1 200]); %200x200x200 magic squares
% Mmed = median(reshape(M(:,:,34),[],1)); %34th slice
%
% %Using the vec() function
% Mmed = median(vec(M(:,:,34)));
%
%Input Arguments:
% -m: matrix of any size
%
%Output Arguments:
% -v: m(:)
%
%See Also: colon reshape
%
v = reshape(m,numel(m),1);
end
Add it to your code.
Or just use
v = v(:);

标签

Community Treasure Hunt

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

Start Hunting!

Translated by