Matrix with unknown values

6 visualizaciones (últimos 30 días)
Marianna
Marianna el 7 de Feb. de 2018
Comentada: Marianna el 8 de Feb. de 2018
Dear community, I am loosing my mind with this simple problem:
A = B .* X
where A and B are two arrays [3x1x80] and X is a matrix [3x3x80].
As X has 5 unknown values I tried to implement this matrix equation with fminsearch:
function [estimates,model] = findvalues(A,B)
X0 = [0.1 0.1 0.2 0.3 0.56];
model = @maps;
options=optimset('Display','off','MaxIter',100000,'MaxFunEvals',100000,'TolX',1e-8);
[estimates] = fminsearch(model, X0, options);
function [ FittedCurve,sse] = maps(params)
X = zeros(3,3,80);
a = params(1);
b = params(2);
c = params(3);
d = params(4);
e = params(5);
X(1,1,:) = -(Rb + (1 ./ a));
X(1,2,:) = (1 ./ b) - (((e - (1 - f)) ./ f) ./ (V ./ f) .* (1 ./ c));
X(2,1,:) = (1 ./ a);
c = -(((r1o .* CRo) + R1o0) + (1 ./ b));
X(2,2,:) = c';
X(2,3,:) = (1 ./ c);
X(3,2,:) = (1 ./ b) - ((d./(V.*(1-h))).*(1./a));
X(3,3,:) = (-(Ri + (1 ./ c)));
for i = 1:80
FittedCurve(:,:,i) = mtimes( ((sin(a) .* (I - ((exp(X(:,:,i))).^TR))) , B);
end
ErrorVector = FittedCurve - A;
sse = sum((ErrorVector .^ 2),3);
end
end
It does not work. Is it because maybe fminsearch is not the most suitable function for this problem? Or is there a conceptual mistake?
I really thank you for the support.
  2 comentarios
Jan
Jan el 7 de Feb. de 2018
Editada: Jan el 7 de Feb. de 2018
Please fix:
A and X are two arrays [3x1x80] and X is a matrix [3x3x80].
One of the matrices is B.
Please explain "in does not work" with any details. It is easier to suggest a solution than to guess the problem.
Marianna
Marianna el 7 de Feb. de 2018
Thank you. I get this error:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
Error in findvalues (line 17)
[estimates] = fminsearch(model, start_point, options);

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Feb. de 2018
Your function must return a scalar to be used with fminsearch. You have 3D array A so ErrorVector is 3D and you sum() the square of that over the 3rd dimension, which is going to give you a 2D array instead of a scalar.
  3 comentarios
Walter Roberson
Walter Roberson el 8 de Feb. de 2018
No, I think the solution is
sse = sum(ErrorVector(:) .^ 2);
Marianna
Marianna el 8 de Feb. de 2018
Ok. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by