It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a nonlinear function to minimize, that satisfies a linear inequality constraint and a non-negativity constraint. I use fmincon setting the lower bound to 0 for this.
It seems that the answer I get does not satisfy x >= 0, although the linear inequality constraint is satisfied. I am not sure if the function I am trying to minimize is convex (It may have local minima), but I do not think this should affect anything.
FYI here is the syntax I am using:
h = fmincon(#(x)constraint_test(x,s,Cov), A,b, [],[], 0,[])
constraint_test is the function to be minimized, all other variables (s,Cov,A,b) are known.
The function fmincon has a bunch of additional outputs
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA] = fmincon(...)
of which EXITFLAG and OUTPUT provide all sorts of information on how the optimization terminated. Additionally, you can pass in an option:
options = optimset('display', 'iter-detailed');
h = fmincon(..., options);
which will show you exactly what fmincon is deciding and doing on each iteration.
It sounds like it just wasn't able to find any feasible solution, which is something that will definitely show up when you analyze these outputs.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm using the convex optimisation toolbox in matlab and the objective function gets minimized and the value is shown. But the optimisation variable for which minima is achieved, I cannot find. Will someone tell me how to find it?
You didn't say which function you are using to perform the optimization, but most or all of them return the location of the minimum as the first argument. See fmincon for example.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
In order to do a quadratic regression on a rather large data set I would like to solve the following equation using svd(singular value decomposition):
B(nx1)=A(nx3)*X(3x1)
I am thinking to use matlab for that, any tips? the goal is to compute matrix X
It seems that what you call quadratic regression is actually the minimal square error regression. In this case the computation is very easy:
1) Multiply both left sides by A'(3xn) arriving to
A'(3xn)B(nx1) = A'(3xn)A(nx3) X(3x1)
2) Now multiply both left sides by the inverse of A'(nx1) A(nx3) arriving to
inv(A'(3xn)A(nx3))A'(3xn)B(nx1) = X(3x1)
3) Now use svd to evaluate the inverse above, see Most efficient matrix inversion in MATLAB
See also Minimizing error of a formula in MATLAB (Least squares?)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am new to Matlab and I want to write a matlab program for global optimization. I have an objective function f(x), a domain D, and co-domain R. I have looked at Optimization toolbox, but it show reference and examples of local minimization only.
If someone can give me a few hints on global optimization in Matlab, that will be very helpful.
Optimization Toolbox, as you've discovered, only handles "local" optimization - algorithms such as linear, quadratic and binary programming, nonlinear optimization etc. You might like to take a look at Global Optimization Toolbox, which contains global optimization algorithms such as genetic algorithms, simulated annealing and others..
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a vector of values corresponding to the measured data and I want to predict the next values. How can I do that? I know that is possible with Kalman filter but it might be an easier way to do. Here is a plot of the data and I want to predict next values:
Try exponential smoothing, e.g., double exponential smoothing or Holt-Winters method. Basically you try to learn the trend of the data.
I have some sample python code in this post.
On the other hand, if you know the movement/observation model of the underline variable, for sure, kalman will give you much better predictions as #tomasz74 pointed out.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Could you help me to write matlab simple code for k-means algorithm without using the algorithm in matlab toolbox ? So i want to work with array and plot the clusters with unique colors. For example i have an array=[1 2; 3 4 ; 5 6] with 2 clusters; some points will be red some points are blue at the end the program should plot the array in axis. then using the k-means algorithm. at the end. plot clusters in graphical interface.
can you help me?
If you want to see how MATLAB does it, type
edit kmeans
into the command window. This might give you some hints.
An easier place to start would probably be the wikipedia page, which has the basic algorithm succinctly outlined.