abdfahim
abdfahim

Reputation: 2553

Matrix Function Minimization

I have a function A = X + W .* Y where all of the variables are (M x N) matrices.

I want to minimize sqr(A) over W such that the elements of W follow the equation: W(m,n) = W(m,n-1) + 0.5

I was studying matlab default functions like fminsearch or fmincon, but couldn't actually relate to what I want.

If anybody can please show me the direction.

Thanks

Upvotes: 0

Views: 477

Answers (1)

user1543042
user1543042

Reputation: 3440

I think this is what you want:

M = 7;
N = 4;
X = rand(M,N);
Y = rand(M,N);

% This makes a matrix that follows your rule for W, because there are only M unique elements with the rule.
W =@(x,n) repmat(x(:), 1, n) + repmat(0:0.5:0.5*(n-1), numel(x), 1);
A =@(x,n) X + W(x,n) .* Y;

y = fminsearch(@(y) norm(A(y, N)), rand(M, 1))
w = W(y, N)
a = A(y, N)

Upvotes: 1

Related Questions