Specifying positive solutions for a system of non-linear equations - matlab

I want to solve a system of non-linear equations in matlab such that the solutions are positive. Can I specify in matlab that I want positive solutions for unknown variables? How?

Yes, you can define the variables with syms like:
syms x y positive
and those variables are constained to be positive. See fsolve for how to find the solution after you have define the constraints on variables.

Related

'solve' syntax in MATLAB for symbolic nonlinear matrix equation

I have a symbolic matrix that depends on a complex parameter q. Let the matrix be A(q) and b a column vector. I would like to simultaneously solve the equations
A*b==0; b'*b==1;
using the solve command (preferably the numerical variant vpasolve). The variables to be found are both b and q. I am not quite sure about the syntax on how to do this and would appreciate any help on it. My main problem is that the equation is partially given in matrix form and the searched variable is a vector.
Do I have to resort to fsolve to achieve this? Or is there a way without defining a function?

Nonlinear optimization with symbolic constraint in Matlab

I need to solve a nonlinear problem in n symbolic variables. The objective function to maximize is just a sum/difference of products of a variable with itself or with another one, so it is basically a quadratic equation.
The problem is that I need to impose a symbolic limit on the sum of these variables, as well as limit the values of these variables to be between 0 and 1 inclusive.
So I need an upper bound expressed as a function of the (symbolic) sum and not as a number. Can Matlab solve such kind of problems? If yes, how?
EDIT: Basically I need to perform the optimization of a symbolic problem with a quadratic objective function and linear constraints.

Using MATLAB's solve function to find solution to system of equations

I am having trouble solving a system of equations. I have three equations with a known solution and three unknowns in each equation. However, when I use the solve function in MATLAB, it returns with the error that I have six equations and three variables.
A snippet of my code:
syms V0 T0 X0
A=(g*X0/(2*V0^2*cos(T0)^2)-tan(T0))==a;
B=(tan(T0)-g*X0/(V0^2*cos(T0)^2))==b;
C=(-g/(2*V0^2*cos(T0)^2))==c;
soln=solve([A,B,C],[V0,T0,X0]);
I have already calculated scalar values for a, b, and c. g is a constant.
I am not sure why it is returning that I have six equations.
V0^2 means its a quadratic equation. You could solve for V0^2 as a variable. Set V0^2 = J0 and solve for J0 instead.
soln=solve([A,B,C],[J0,T0,X0]);
Then its three linear equations with three variables.
Once you get value of J0, then you need to solve for V0^2 = J0.

Solve maximization problem of quadratic equation in MATLAB

How do I solve a quadratic Maximization problem in MATLAB? It seems MATLAB only supports minimization problems, so is there a mathematical concept I can use?
simply multiply by (-1) before and after using the minimization function
Using quadprog function in MATLAB.
This function solves Quadratic Programming problems in MATLAB.
Of course if you want the maxima instead of the minima, you can multiply the cost function by -1.
Good Luck.
The above answer #Drazick seems not right.
quadprog() in matlab requires H to be positive definite. If we simply multiply (-1), -H is a negative definite matrix, which violates the requirement.
Another optimization function called fmincon( ) may help.

How to solve complex system of equations using matlab?

I have to analyze 802.11 saturation throughput using matlab, and here is my problem. I'm trying to solve parametric equations below (parameters are m,W,a) using solve function and i get
Warning: Explicit solution could not be found
How could I solve above equations using matlab?
I guess you were trying to find an analytical solution for tau and p using symbolic math. Unless you're really lucky with your parameters (e.g. m=1), there won't be an analytical solution.
If you're interested in numerical values for tau and p, I suggest you manually substitue p in the first equation, and then solve an equation of the form tau-bigFraction=0 using, e.g. fzero.
Here's how you'd use fzero to solve a simple equation kx=exp(-x), with k being a parameter.
k = 5; %# set a value for k
x = fzero(#(x)k*x-exp(-x),0); %# initial guess: x=0