Today in the use of MATLAB and accumulated two points, now summarized as follows
1, Objective function is undefined at the initial point. Fmincon cannot continue. Error resolution
When using fmincon, this error is most likely that you solve the input matrix there are non-numeric values, such as Nan, please carefully check whether the input parameter matrix contains Nan and so on, if any will be removed.
2, then how to remove the matrix contains Nan's row or column it.
It is easier to remove Nan from a certain location, but it is more difficult to get rid of the line or column where Nan is located, provided that you are not familiar with MATLAB, and if you know it differently.
No nonsense, just say the solution, add a matrix
A=[1,2,nan;
3,nan,4;
5,6,7]
If you are a single line representing a sample, then the first and second rows have to be removed because their eigenvalues contain Nan.
Just one line of code can be done.
A= (All (~isnan (A), 2),:);
(1) It is so simple, which uses the all function, all (a,2) means that if a row of a does not have a non-0 value, then the row return value is 1, if the row contains a non-0 value, the row return value is 0, and eventually returns a column vector. Each element represents whether a row of a is a non-0 value. 1 means that a row is all a non-0 value, and 0 means no. I
(2) isNaN will not introduce, self-Baidu
(3) and all the same usage also has any, can also use any to do, extract does not contain Nan's non-0 columns, everyone will write.